aboutsummaryrefslogtreecommitdiff
path: root/pyenc/db.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyenc/db.py')
-rw-r--r--pyenc/db.py28
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)