You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
331 B

  1. import sqlite3
  2. import click
  3. from flask import current_app, g
  4. from flask.cli import with_appcontext
  5. def get_db():
  6. if 'db' not in g:
  7. g.db = sqlite3.connect(current_app.config['DATABASE'])
  8. g.db.row_factory = sqlite3.Row
  9. return g.db
  10. def close_db()
  11. db = g.pop('db', None)
  12. if db is not None:
  13. db.close()