Fixed flask tests

This commit is contained in:
Armin Ronacher 2014-05-02 11:46:04 +01:00
parent e059bf311c
commit d2d8e66130
5 changed files with 23 additions and 10 deletions

View file

@ -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)