Added pool_recycle every hour
This commit is contained in:
parent
eab94e1c01
commit
b0599c1484
@ -3,11 +3,13 @@ from sqlalchemy.future import Engine
|
|||||||
|
|
||||||
from . import models # noqa
|
from . import models # noqa
|
||||||
|
|
||||||
|
HOUR_IN_SECONDS = 3600
|
||||||
|
|
||||||
|
|
||||||
def get_engine(host: str, user: str, passwd: str, db: str) -> Engine:
|
def get_engine(host: str, user: str, passwd: str, db: str) -> Engine:
|
||||||
"""Creates an engine for mariadb with pymysql as connector"""
|
"""Creates an engine for mariadb with pymysql as connector"""
|
||||||
uri = f"mariadb+pymysql://{user}:{passwd}@{host}/{db}"
|
uri = f"mariadb+pymysql://{user}:{passwd}@{host}/{db}"
|
||||||
engine = sqlmodel.create_engine(uri)
|
engine = sqlmodel.create_engine(uri, pool_recycle=HOUR_IN_SECONDS)
|
||||||
return engine
|
return engine
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user