mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 12:43:12 +03:00
refactor(chart): Added docstring in each file and function. Fixed long lines
This commit is contained in:
parent
c5d3d9fe9b
commit
ed8cf91558
7 changed files with 190 additions and 30 deletions
|
@ -1,9 +1,27 @@
|
|||
import asyncpg
|
||||
import yaml
|
||||
"""
|
||||
This module initializes the database connection pool using asyncpg.
|
||||
|
||||
config = yaml.safe_load(open("config.yaml", "r"))
|
||||
It reads database configuration from a YAML file and creates a connection pool
|
||||
that can be used throughout the application for database operations.
|
||||
"""
|
||||
|
||||
import asyncpg
|
||||
|
||||
from chart.utils.load_config import load_config
|
||||
|
||||
config = load_config('config.yaml')
|
||||
|
||||
async def create_pool() -> asyncpg.pool.Pool:
|
||||
"""
|
||||
Creates and returns a connection pool for the PostgreSQL database.
|
||||
|
||||
The function uses configuration settings loaded from a YAML file to
|
||||
establish the connection pool. The pool allows multiple database
|
||||
connections to be reused efficiently across the application.
|
||||
|
||||
Returns:
|
||||
asyncpg.pool.Pool: The connection pool object.
|
||||
"""
|
||||
pool = await asyncpg.create_pool(
|
||||
user=config['database']['user'],
|
||||
password=config['database']['password'],
|
||||
|
@ -14,4 +32,4 @@ async def create_pool() -> asyncpg.pool.Pool:
|
|||
max_size=20
|
||||
)
|
||||
|
||||
return pool
|
||||
return pool
|
||||
|
|
Loading…
Add table
Reference in a new issue