diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-02-27 17:31:50 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-02-27 17:31:50 +0100 |
commit | bbd692427632bf525f0fa46eeab0de0f8a563661 (patch) | |
tree | 6c13fdc978e3b5e97498bc16322d5ee56c8c1617 /pyenc/db.py | |
parent | Initial commit. (diff) | |
download | puppet-classifier-bbd692427632bf525f0fa46eeab0de0f8a563661.tar.gz puppet-classifier-bbd692427632bf525f0fa46eeab0de0f8a563661.tar.xz |
Initial code add.
Diffstat (limited to 'pyenc/db.py')
-rw-r--r-- | pyenc/db.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pyenc/db.py b/pyenc/db.py new file mode 100644 index 0000000..ea7cc14 --- /dev/null +++ b/pyenc/db.py @@ -0,0 +1,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) |