I'm trying to connect my application to postgresql database through peewee.
config.ini
:
[DEFAULT]
discord_key = apikey
# private token from discord developer porter
psql_user = postgres
# username for postgres database
psql_db = test
# database name
owner_id = owner
# discord user ID of bot installation owner.
Here is the error I'm getting:
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/peewee.py", line 3033, in __enter__
self.db.connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/peewee.py", line 3136, in connect
self._initialize_connection(self._state.conn)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/peewee.py", line 2970, in __exit__
reraise(new_type, new_type(exc_value, *exc_args), traceback)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/peewee.py", line 191, in reraise
raise value.with_traceback(tb)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/peewee.py", line 3133, in connect
self._state.set_connection(self._connect())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/playhouse/postgres_ext.py", line 471, in _connect
conn = super(PostgresqlExtDatabase, self)._connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/peewee.py", line 3866, in _connect
conn = psycopg2.connect(**params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/psycopg2/__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
peewee.OperationalError: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: password authentication failed for user "postgres"
The bot.py file is here.
AFAIU peewee needs my psql password to authenticate the connection but I don't know how to pass the password in the config file.
CodePudding user response:
I'm not sure where you got this code, but it looks like maybe it hardcodes the password? https://github.com/the-brainiac-1869/Polytopia-ELO-Bot/blob/master/modules/models.py#L25