# Path: ramjet/models/base.py
# class BaseMySQLModel(MySQLdbExceptionHandler):
#     _db_pool = None
# 
#     def __init__(self):
#         self._db_pool = None
# 
#     @classmethod
#     async def make_connection(cls):
#         if cls._db_pool:
#             return cls
# 
#         cls._db_pool = await aiomysql.create_pool(
#             host=opt.DATABASES[cls._db_name]['HOST'],
#             port=opt.DATABASES[cls._db_name].get('PORT', None),
#             user=opt.DATABASES[cls._db_name]['USER'],
#             password=opt.DATABASES[cls._db_name]['PASSWORD'],
#             db=opt.DATABASES[cls._db_name]['NAME'],
#             cursorclass=aiomysql.cursors.SSCursor,
#             charset='utf8mb4'
#         )
#         return cls
# 
#     @classmethod
#     @async_contextmanager
#     async def get_conn(cls):
#         """Get connection without autocommit"""
#         await cls.make_connection()
#         async with cls._db_pool.acquire() as conn:
#             yield conn
# 
#     @classmethod
#     @async_contextmanager
#     async def get_cursor(cls):
#         """Simple way to get cursor with autocommit"""
#         await cls.make_connection()
#         async with cls.get_conn() as conn:
#             async with conn.cursor() as cursor:
#                 yield cursor
#             await conn.commit()
# 
#     @classmethod
#     async def close(cls):
#         return cls._db_pool.close()


from .base import BaseMySQLModel


def create_mysql_model(db_name):
    class Model(BaseMySQLModel):
        _db_name = db_name

    return Model


_models = {}

def get_mysql_model(db_name):
    if db_name in _models:

# Path: ramjet/models/base.py
# class BaseMySQLModel(MySQLdbExceptionHandler):
#     _db_pool = None
# 
#     def __init__(self):
#         self._db_pool = None
# 
#     @classmethod
#     async def make_connection(cls):
#         if cls._db_pool:
#             return cls
# 
#         cls._db_pool = await aiomysql.create_pool(
#             host=opt.DATABASES[cls._db_name]['HOST'],
#             port=opt.DATABASES[cls._db_name].get('PORT', None),
#             user=opt.DATABASES[cls._db_name]['USER'],
#             password=opt.DATABASES[cls._db_name]['PASSWORD'],
#             db=opt.DATABASES[cls._db_name]['NAME'],
#             cursorclass=aiomysql.cursors.SSCursor,
#             charset='utf8mb4'
#         )
#         return cls
# 
#     @classmethod
#     @async_contextmanager
#     async def get_conn(cls):
#         """Get connection without autocommit"""
#         await cls.make_connection()
#         async with cls._db_pool.acquire() as conn:
#             yield conn
# 
#     @classmethod
#     @async_contextmanager
#     async def get_cursor(cls):
#         """Simple way to get cursor with autocommit"""
#         await cls.make_connection()
#         async with cls.get_conn() as conn:
#             async with conn.cursor() as cursor:
#                 yield cursor
#             await conn.commit()
# 
#     @classmethod
#     async def close(cls):
#         return cls._db_pool.close()


# Path: ramjet/models/mysql_dbs.py
from .base import BaseMySQLModel



def create_mysql_model(db_name):
    class Model(BaseMySQLModel):
        _db_name = db_name

    return Model


_models = {}

def get_mysql_model(db_name):
    if db_name in _models:

        model = _models[db_name]