]>
git.datanom.net - liogui.git/blob - webapp/db.py
2 from datetime
import datetime
5 from flask
import current_app
, g
10 with current_app
.open_resource('schema.sql') as f
:
11 db
.executescript(f
.read().decode('utf8'))
13 @click.command('init-db')
14 def init_db_command():
15 """Clear the existing data and create new tables."""
17 click
.echo('Initialized the database.')
19 sqlite3
.register_converter(
20 "timestamp", lambda v
: datetime
.fromisoformat(v
.decode())
24 app
.teardown_appcontext(close_db
)
25 app
.cli
.add_command(init_db_command
)
29 g
.db
= sqlite3
.connect(
30 current_app
.config
['DATABASE'],
31 detect_types
=sqlite3
.PARSE_DECLTYPES
33 g
.db
.row_factory
= sqlite3
.Row
39 db
= g
.pop('db', None)
This page took 0.914958 seconds and 6 git commands to generate.