def init_gopdb(db_info): def func(engine): pass # engine.execute("ALTER TABLE %s AUTO_INCREMENT = 1" % GopDatabase.__tablename__) # engine.execute("ALTER TABLE %s AUTO_INCREMENT = 1" % RecordDatabase.__tablename__) # engine.execute("ALTER TABLE %s AUTO_INCREMENT = 1" % GopSchema.__tablename__) # engine.execute("ALTER TABLE %s AUTO_INCREMENT = 1" % SchemaQuote.__tablename__) init_database(db_info, TableBase.metadata, init_data_func=func)
def init_plugin_database(db_info, *models): """Table in models must base on PluginTableBase So that table in models can be carete when call init_database """ def init_plugin_data(engine): session_maker = orm.get_maker(engine=engine) session = session_maker() with session.begin(): # Start from 1 # So 1-2047 can be used as gkey id for i in xrange(1, 2048): row = GkeyMap(sid=i, host=None) session.add(row) session.flush() for _models in models: if hasattr(_models, 'init_data'): getattr(_models, 'init_data')(session) session.close() init_database(db_info, metadata=PluginTableBase.metadata, init_data_func=init_plugin_data)
def init_fluttercomic(db_info): init_database(db_info, TableBase.metadata)
from simpleservice.ormdb.tools.utils import init_database from simpleservice.plugin.models import PluginTableBase dst = { 'host': '172.20.0.3', 'port': 3304, 'schema': 'manager', 'user': '******', 'passwd': '111111' } init_database(dst, PluginTableBase.metadata)
def init_webadmin(db_info): init_database(db_info, TableBase.metadata)
def init_gopdb(db_info): init_database(db_info, TableBase.metadata)
def init_simpleflowdb(db_info): init_database(db_info, models.SimpleFlowTables.metadata)