I'm trying to create/connect a postgres database to a Pony ORM web application that I'm doing. At first I used a sqlite database with Pony ORM and everything worked fine but I need to switch to postgres since I want to put it up on Heroku. I used the graphic postgres tool and created a database called "notice_db" and a postgres user called notice. My code for binding the database with pony is:
db = Database()
db.bind('postgres', user='notice', password='Notice',host='localhost', database='notice_db', dbname='notice_db', port='5432')
It will find the user and connect to localhost but no database will be connected or created so when I try to use the Pony ORM functions like creating an database entity for my User class which has the attribute "username" I get this error: "ProgrammingError: column "username" does not exist LINE 1: select * from User where username = 'user1'".
Pony does not connect to or create postgres database. So I wonder how I connect a postgres database to a Pony ORM application?
Why are you defining dbname and database? The parameter 'dbname' doesn't work for a postgres connection from pony. Use 'database' instead of 'dbname':
db.bind('postgres', user='notice', password='Notice',
host='localhost', database='notice_db', port='5432')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.