first_commit .gitignore

This commit is contained in:
hibiki
2021-05-20 18:37:51 +08:00
parent df4e3aea45
commit 155f62c08a
947 changed files with 26899 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
from gino import Gino
from .log import logger
from configs.config import bind, sql_name, user, password, address, port, database
# 全局数据库连接对象
db = Gino()
async def init():
i_bind = bind
if not bind:
i_bind = f"{sql_name}://{user}:{password}@{address}:{port}/{database}"
# print(i_bind)
try:
await db.set_bind(i_bind)
await db.gino.create_all()
logger.info(f'Database loaded successfully!')
except Exception as e:
raise Exception(f'数据库连接错误.... e: {e}')
async def disconnect():
await db.pop_bind().close()