File size: 755 Bytes
9cb712d
 
4995bb4
aa34f6b
57d78b2
aa34f6b
 
 
 
 
 
 
 
 
 
 
 
4995bb4
 
 
9cb712d
 
 
 
 
 
 
 
 
57d78b2
4d860a2
 
 
 
 
 
aa34f6b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, Session
from app.core.config import settings
from psycopg_pool import ConnectionPool
from contextlib import contextmanager



DB_URL_FOR_CHECKPOINTER_STORE=settings.DB_URL_FOR_CHECKPOINTER_STORE

pool = ConnectionPool(
    conninfo=DB_URL_FOR_CHECKPOINTER_STORE, 
    min_size=1, 
    max_size=10,
    kwargs={"autocommit": True} 
)


DB_URL_FOR_SQL_AL=settings.DB_URL_FOR_SQL_AL

engine = create_engine(
    DB_URL_FOR_SQL_AL, 
    echo=False, 
    pool_pre_ping=True, 
    pool_recycle=1800
)

SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False)


def get_session():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()