mirror of
https://github.com/Redume/StarBoard.git
synced 2025-04-07 04:05:28 +01:00
27 lines
No EOL
610 B
Python
27 lines
No EOL
610 B
Python
import json
|
|
|
|
import asyncpg
|
|
import yaml
|
|
|
|
config = yaml.safe_load(open("config.yaml", "r"))
|
|
|
|
async def pg_con():
|
|
try:
|
|
con = await asyncpg.connect(
|
|
user=config['database']["user"],
|
|
password=config['database']["password"],
|
|
database=config['database']["database"],
|
|
host=config['database']["host"],
|
|
port=5432
|
|
)
|
|
|
|
await con.set_type_codec(
|
|
'json',
|
|
encoder=json.dumps,
|
|
decoder=json.loads,
|
|
schema='pg_catalog'
|
|
)
|
|
|
|
return con
|
|
except Exception as e:
|
|
print(e) |