Answer the question
In order to leave comments, you need to log in
How to connect to psql on Ubuntu using aiogram library?
There is a small telegram bot written in Python using the aiogram library. I'm trying to run it on the server, but it gives me an error that it's impossible to connect to the PostgreSql database. I acted in the following order:
Installed postgresql on ubuntu:
sudo apt -y install postgresql
Then switched to the postgres user using the command:
sudo -i -u postgres
Created an additional role and gave superuser rights:
createuser --interactive
Enter name of role to add: username
Shall the new role to be a superuser (y/n)?: y
createdb username
class PgDatabaseAPI:
def __init__(self, loop: asyncio.AbstractEventLoop):
self.pool: asyncpg.pool.Pool = loop.run_until_complete(
asyncpg.create_pool(
user='username',
password='mylongpassword', # здесь указал пароль от учетной записи ubuntu с одноименным именем username
host='localhost'
)
)
asyncpg.exceptions.InvalidPasswordError: password authentication failed for user "username"
Answer the question
In order to leave comments, you need to log in
# here I specified the password for the ubuntu account with the same name username
\password
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question