|
|
|
@ -49,15 +49,21 @@ def close_database(exception):
|
|
|
|
|
top.sqlite_db.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.cli.command() |
|
|
|
|
def initdb(): |
|
|
|
|
"""Creates the database tables.""" |
|
|
|
|
def init_db(): |
|
|
|
|
"""Initializes the database.""" |
|
|
|
|
db = get_db() |
|
|
|
|
with app.open_resource('schema.sql', mode='r') as f: |
|
|
|
|
db.cursor().executescript(f.read()) |
|
|
|
|
db.commit() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.cli.command('initdb') |
|
|
|
|
def initdb_command(): |
|
|
|
|
"""Creates the database tables.""" |
|
|
|
|
init_db() |
|
|
|
|
print('Initialized the database.') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def query_db(query, args=(), one=False): |
|
|
|
|
"""Queries the database and returns a list of dictionaries.""" |
|
|
|
|
cur = get_db().execute(query, args) |
|
|
|
|