[英]How to set Postgres username and password in the Flask Peewee ORM?
我正在使用Python Flask框架以及Peewee ORM和PostgreSQL作為數據庫來構建網站。 在我的Mac上進行開發時,此方法工作正常。 我現在將安裝轉移到我的Ubuntu 12.04桌面上,以在Linux上進行一些測試,現在我遇到了Postgresql的麻煩。 在我的Mac上,postgres服務器似乎不需要用戶名和密碼(對開發有益,對生產不利)。 現在在Ubuntu上說
OperationalError: FATAL: role "kramer65" does not exist
kramer65是我在Ubuntu中的普通用戶名,因此顯而易見,postgres不知道。 我可以使用postgres用戶登錄psql,但是我不知道如何將其添加到peewee。 我有一個配置文件,其中:
DATABASE = {
'name': 'mydb',
'engine': 'playhouse.postgres_ext.PostgresqlExtDatabase'
}
我嘗試在其中添加'password': 'mypassword'
和'username': 'myusername'
,但隨后顯示OperationalError: invalid connection option "username"
。
知道如何將用戶名和密碼添加到peewee以連接到PostgreSQL數據庫嗎? 歡迎所有提示!
我從未聽說過peewee,也從未使用過它,但是github上的示例postgres連接呢 ? 而且由於peewee似乎將psycopg2用於Postgres連接,因此應使用其所有連接選項。
您需要使用'user': 'yourusername'
代替'username': 'yourusername'
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.