blob: 38edda10decbce6d771635f933689b7cf45c2d1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
"""Database connection for application."""
import click
from flask import current_app, g
from flask.cli import with_appcontext
from .model import db
@click.command('init-db')
@with_appcontext
def init_db_command():
"""Create database from command line."""
# init_db()
# print(db)
print(db)
db.create_all()
click.echo('Initialized the database.')
def init_app(app):
"""Add database (and click) to given flask app."""
# app.teardown_appcontext(close_db)
db.init_app(app)
app.cli.add_command(init_db_command)
|