Files
bookshelf/back/database.py
2026-01-29 15:26:33 +01:00

17 lines
373 B
Python

from back.secret import host, user, password, database
import pymysql.cursors
def get_db():
connection = pymysql.connect(
host=host,
user=user,
password=password,
database=database,
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor
)
try:
yield connection
finally:
connection.close()