def build_db(): ''' delete all, then rebuild db ''' db.drop_all() db.create_all() return 'build database success.'
def run(self, argv): dir = os.path.join(os.path.expanduser('~'), '.redis-monitor') if not os.path.exists(dir): os.makedirs(dir) if os.path.isdir(dir): path = os.path.join(dir, 'redis_monitor_config.py') if os.path.exists(path): print('Fail: the configuration file exist in `%s`.' % path) else: sqlite_file = os.path.join(dir, 'redis_monitor.db') \ .replace('\\', '/') with open(path, 'w') as f: f.write(CONFIG_TEMP % sqlite_file) print('OK: init configuration file into `%s`.' % path) db.create_all() print('OK: database is initialed into `%s`.' % sqlite_file) else: print('Fail: %s should be directory.' % dir)
def createdb(drop_first=False): """Creates the database.""" if drop_first: db.drop_all() db.create_all() print('OK: database is initialed.')
def app(): SQLAlchemyDB.create_all() yield _app SQLAlchemyDB.session.close() SQLAlchemyDB.drop_all()
def build_db(): # database init db.drop_all() db.create_all() return 'build database success.'
def rebuild_db(): db.create_all()
def rebuild_db(): db.create_all() return 'rebuild database success.'