aboutsummaryrefslogtreecommitdiff
path: root/pyenc/db.py
blob: ea7cc14c661153fd1e0e121fd89d1ce15a34428f (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
25
26
27
28
"""
Database connection for application
"""

import click
from flask import current_app, g
from flask.cli import with_appcontext
from .model import db

@with_appcontext
def init_db():
    db.create_all()

@click.command('init-db')
@with_appcontext
def init_db_command():
    """
    """
    # init_db()
    #print(db)
    print(db)
    db.create_all()
    click.echo('Initialized the database.')

def init_app(app):
    # app.teardown_appcontext(close_db)
    db.init_app(app)
    app.cli.add_command(init_db_command)