How to create / mount a postgres database in Pony ORM?

I am trying to create / connect a postgres database to the Pony ORM web application that I am doing. At first I used the sqlite database with Pony ORM and everything worked fine, but I need to switch to postgres since I want to host it on Heroku. I used the graphical postgres tool and created a database called "notice_db" and the postgres user called a notification. My code for binding database to pony:

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 Pony ORM functions, such as creating a database object for my User class that has the username attribute, I I get this error: "ProgrammingError: column" username "does not exist LINE 1: select * from the user, where username = 'user1'".

Pony does not connect and does not create a postgres database. So I wonder how do I connect a postgres database to a Pony ORN application?

+4
source share

Source: https://habr.com/ru/post/1626425/


All Articles