Выложил бота на новом сервере и он создал новую БД
Проблема в том что я не могу понять как подключится к старой БД (Postgresql)
Бот собирается через docker-compose
class Database:
def __init__(self):
self.pool: Union[Pool, None] = None
async def create(self):
self.pool = await asyncpg.create_pool(
user=config.DB_USER,
password=config.DB_PASS,
host=config.DB_HOST,
database=config.DB_NAME
)
async def execute(self, command, *args,
fetch: bool = False,
fetchval: bool = False,
fetchrow: bool = False,
execute: bool = False):
async with self.pool.acquire() as connection:
connection: Connection
async with connection.transaction():
if fetch:
result = await connection.fetch(command, *args) # - все записи списком
elif fetchval:
result = await connection.fetchval(command, *args) # - одна запись
elif fetchrow:
result = await connection.fetchrow(command, *args) # - первая строка
elif execute:
result = await connection.execute(command, *args)
return result
async def create_tables(self):
for table in create_tables_rows():
await self.execute(table, execute=True)