Вопрос

I'm building a website using the Python Flask framework and the Peewee ORM and PostgreSQL as a database. This worked fine when developing on my Mac. I now moved the installation to my Ubuntu 12.04 desktop to do some testing on Linux and I now run into trouble with Postgresql. On my Mac, the postgres server didn't seem to require a user and password (good for devving, bad for production). On Ubuntu it now says

OperationalError: FATAL:  role "kramer65" does not exist

kramer65 is my normal username in Ubuntu , so it should be obvious that postgres doesn't know it. I can log into psql using the postgres user, but I don't know how to add it to peewee. I've got a config file in which I have:

DATABASE = {
    'name': 'mydb',
    'engine': 'playhouse.postgres_ext.PostgresqlExtDatabase'
}

I tried adding 'password': 'mypassword' and 'username': 'myusername' to it, but then it says OperationalError: invalid connection option "username".

Any idea how I can add the username and password to peewee to connect to my PostgreSQL database? All tips are welcome!

Это было полезно?

Решение

I never heard of peewee nor worked with it but what about the example postgres connection from the github. And since peewee seems to use psycopg2 for Postgres connectivity, all of their connection options should apply.

You need to use 'user': 'yourusername' instead of 'username': 'yourusername'.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top