From 110effaeb285009e7268147b0cc807b718503a03 Mon Sep 17 00:00:00 2001 From: Redume Date: Sat, 14 Dec 2024 23:21:28 +0300 Subject: [PATCH] chore(chart): Switched to a new library to work with postgres. From psycopg2 to asynpg --- chart/database/server.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 chart/database/server.py diff --git a/chart/database/server.py b/chart/database/server.py new file mode 100644 index 0000000..6c8934e --- /dev/null +++ b/chart/database/server.py @@ -0,0 +1,17 @@ +import asyncpg +import yaml + +config = yaml.safe_load(open("config.yaml", "r")) + +async def create_pool() -> asyncpg.pool.Pool: + pool = await asyncpg.create_pool( + user=config['database']['user'], + password=config['database']['password'], + database=config['database']['name'], + host=config['database']['host'], + port=config['database']['port'], + min_size=5, + max_size=20 + ) + + return pool \ No newline at end of file