forked from Infra/risotto
set docker
This commit is contained in:
@ -12,7 +12,8 @@ from pathlib import PurePosixPath
|
||||
CURRENT_PATH = PurePosixPath(__file__)
|
||||
|
||||
def get_config():
|
||||
return {'database': {'host': 'localhost',
|
||||
return {'database': {'engine': 'postgres',
|
||||
'host': 'postgres',
|
||||
'port': 5432,
|
||||
'dbname': 'risotto',
|
||||
'user': 'risotto',
|
||||
@ -30,3 +31,4 @@ def get_config():
|
||||
'source': {'root_path': '/srv/seed'},
|
||||
'cache': {'root_path': '/var/cache/risotto'}
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,17 @@ class RegisterDispatcher:
|
||||
async def load(self):
|
||||
# valid function's arguments
|
||||
db_conf = get_config().get('database')
|
||||
self.pool = await asyncpg.create_pool(database=db_conf.get('dbname'), user=db_conf.get('user'))
|
||||
|
||||
#postgres://user:pass@host:port/database?option=value.
|
||||
engine = db_conf.get('engine')
|
||||
host = db_conf.get('host')
|
||||
dbname = db_conf.get('dbname')
|
||||
dbuser = db_conf.get('user')
|
||||
dbpassword = db_conf.get('password')
|
||||
dbport = db_conf.get('port')
|
||||
cfg = "{}://{}:{}@{}:{}/{}".format(engine, dbuser, dbpassword, host, dbport, dbname)
|
||||
print(cfg)
|
||||
self.pool = await asyncpg.create_pool(cfg)
|
||||
async with self.pool.acquire() as connection:
|
||||
async with connection.transaction():
|
||||
for version, messages in self.messages.items():
|
||||
@ -271,3 +281,4 @@ class RegisterDispatcher:
|
||||
module_name)
|
||||
await self.insert_message(connection,
|
||||
f'{version}.{message}')
|
||||
|
||||
|
Reference in New Issue
Block a user