mirror of
https://github.com/xfgryujk/blivechat.git
synced 2024-12-26 21:00:15 +08:00
26 lines
514 B
Python
26 lines
514 B
Python
# -*- coding: utf-8 -*-
|
|
from typing import *
|
|
|
|
import sqlalchemy.orm
|
|
|
|
import config
|
|
|
|
_engine: Optional[sqlalchemy.Engine] = None
|
|
|
|
|
|
class OrmBase(sqlalchemy.orm.DeclarativeBase):
|
|
pass
|
|
|
|
|
|
def init(_debug):
|
|
cfg = config.get_config()
|
|
global _engine
|
|
# engine = sqlalchemy.create_engine(cfg.database_url, echo=debug)
|
|
_engine = sqlalchemy.create_engine(cfg.database_url)
|
|
|
|
OrmBase.metadata.create_all(_engine)
|
|
|
|
|
|
def get_session() -> sqlalchemy.orm.Session:
|
|
return sqlalchemy.orm.Session(_engine)
|