Пример #1
0
def build_db():
    '''
    delete all, then rebuild db
    '''
    db.drop_all()
    db.create_all()

    return 'build database success.'
Пример #2
0
    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)
Пример #3
0
def createdb(drop_first=False):
    """Creates the database."""
    if drop_first:
        db.drop_all()
    db.create_all()
    print('OK: database is initialed.')
Пример #4
0
def app():
    SQLAlchemyDB.create_all()
    yield _app
    SQLAlchemyDB.session.close()
    SQLAlchemyDB.drop_all()
Пример #5
0
def build_db():
    # database init
    db.drop_all()
    db.create_all()
    return 'build database success.'
Пример #6
0
def rebuild_db():
    db.create_all()
Пример #7
0
def rebuild_db():
    db.create_all()

    return 'rebuild database success.'