def create_db(): """ Created tables within database """ db.create_all(app=create_app()) print("Tables created in database")
def clean_db(): """ Clears records from all tables within database """ db.drop_all(app=create_app()) print("Tables dropped in database") db.create_all(app=create_app()) print("Tables re-created in database")
""" dcmdb's task runner It helps automate some processes mainly for development purposes. """ import os import json from invoke import run as invoke_run from invoke import task from dcmdb import create_app, db from dcmdb.models import DataElement app = create_app() app.test_request_context().push() BASE_DIR = os.path.dirname(os.path.realpath(__file__)) @task def run(): """ Initiates the server """ app.run() @task def install(): """ Installs node, bower packages and creates tables """ print("Installing node packages") invoke_run("npm install") print("Installing bower packages") invoke_run("bower install") create_db()