def app(): app = create_app() app.config.from_object(TestConfig) with app.app_context(): db.create_all() yield app db.session.remove() # looks like db.session.close() would work as well db.drop_all()
def setUpClass(cls): app = create_app() ctx = app.app_context() ctx.push() db.drop_all() db.create_all() create_users() create_products()
def main(): app = create_app() ctx = app.app_context() ctx.push() db.drop_all() db.create_all() create_superuser() create_products()
from WebApp import create_app, db, bcrypt from WebApp.models import User, Link, Role, access import json db.create_all(app=create_app()) app = create_app() # import JSON file # with open('site.json', 'r') as json_file: json_data = json_file.read() print(json_data) data = json.loads(json_data) #print(data) #for d in data['link1']: # print(d.group) # parse JSON file # # Sort Json content into table groups # # remove table attribute from each object # ctx = app.app_context() ctx.push() # for loop through each table group # # for each object in group create based on that table's lable# #in try except block# ctx.pop()
def create_database(app): with app.app_context(): print("[+] Creating all current database") db.create_all()
# -*- coding: utf-8 -*- from WebApp import db db.create_all()
from WebApp import db, create_app app = create_app() with app.app_context(): db.create_all()