def init_db():
    ''' Inititalizes the database '''
    with app.app_context():
        db = get_db()
        with app.open_resource('schema.sql', mode='r') as f:
            db.cursor().executescript(f.read())
        db.commit()
Пример #2
0
def _init_db(sql_file):
    """Initializes the database."""
    try:
        with get_conn().cursor() as cursor:
            # execute schema sql file
            with app.open_resource(sql_file, mode='r') as f:
                sql = f.read()
                print sql
                result = cursor.execute(sql)
                print result
    finally:
        print get_conn().close()
Пример #3
0
def _execute_sql_file(sql_file):
    """Initializes the database."""
    try:
        with get_conn().cursor() as cursor:
            # execute schema sql file
            with app.open_resource(sql_file, mode='r') as f:
                sql = f.read()
                print sql
                result = cursor.execute(sql)
                print result
    finally:
        print get_conn().close()
Пример #4
0
def init_db():
    """Initializes the database."""
    try:
        with _get_conn().cursor() as cursor:
            # execute schema sql file
            with app.open_resource('db/schema/0001/user.sql', mode='r') as f:
                sql = f.read()
                print sql
                result = cursor.execute(sql)
                print result

    finally:
        print _get_conn().close()
Пример #5
0
def init_db():
    with app.app_context():
        db = get_db()
        with app.open_resource('schema.sql', mode='r') as f:
            db.cursor().executescript(f.read())
        db.commit()
Пример #6
0
from server import app, get_db

with app.app_context():
    db = get_db()
    with app.open_resource('schema.sql', mode='r') as f:
        db.cursor().executescript(f.read())
    db.commit()

    print('Initialized the database.')
Пример #7
0
def _init(database):
    app.logger.info('Creating database schema')
    with app.open_resource(schema_path, 'r') as f:
        database.executescript(f.read())
Пример #8
0
def init_db():
    with app.app_context():
        db = get_db()
        with app.open_resource('database.schema', mode='r') as f:
            db.cursor().executescript(f.read())
        db.commit()