import asyncpg
from fastapi import FastAPI
from loguru import logger

from app.core.settings.app import AppSettings


async def connect_to_db(app: FastAPI, settings: AppSettings) -> None:
    logger.info("Connecting to PostgreSQL")

    app.state.pool = await asyncpg.create_pool(
        str(settings.database_url),
        min_size=settings.min_connection_count,
        max_size=settings.max_connection_count,
    )

    logger.info("Connection established")


async def close_db_connection(app: FastAPI) -> None:
    logger.info("Closing connection to database")

    await app.state.pool.close()

    logger.info("Connection closed")

62feae36c74b09f367029b6a9ee83c013e79d80c
<mask token>

<mask token>


async def connect_to_db(app: FastAPI, settings: AppSettings) ->None:
    logger.info('Connecting to PostgreSQL')
    app.state.pool = await asyncpg.create_pool(str(settings.database_url),
        min_size=settings.min_connection_count, max_size=settings.
        max_connection_count)
    logger.info('Connection established')


async def close_db_connection(app: FastAPI) ->None:
    logger.info('Closing connection to database')
    await app.state.pool.close()
    logger.info('Connection closed')

import asyncpg
from fastapi import FastAPI
from loguru import logger
from app.core.settings.app import AppSettings


async def connect_to_db(app: FastAPI, settings: AppSettings) ->None:
    logger.info('Connecting to PostgreSQL')
    app.state.pool = await asyncpg.create_pool(str(settings.database_url),
        min_size=settings.min_connection_count, max_size=settings.
        max_connection_count)
    logger.info('Connection established')


async def close_db_connection(app: FastAPI) ->None:
    logger.info('Closing connection to database')
    await app.state.pool.close()
    logger.info('Connection closed')

import asyncpg
from fastapi import FastAPI
from loguru import logger

from app.core.settings.app import AppSettings


async def connect_to_db(app: FastAPI, settings: AppSettings) -> None:
    logger.info("Connecting to PostgreSQL")

    app.state.pool = await asyncpg.create_pool(
        str(settings.database_url),
        min_size=settings.min_connection_count,
        max_size=settings.max_connection_count,
    )

    logger.info("Connection established")


async def close_db_connection(app: FastAPI) -> None:
    logger.info("Closing connection to database")

    await app.state.pool.close()

    logger.info("Connection closed")
