def recreate(): "Recreates database tables (same as issuing 'drop' and then 'create')" print 'Connected to {}'.format(repr(db.engine.url)) if prompt_bool("Are you sure you want to recreate the database?"): db.drop_all() db.create_all() print 'Database re-created'
from flask import Flask from api.api import api_route from data.db import db from web.web import web_route def register_extensions(app): db.init_app(app) def create_app(): app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://geo.db' app.register_blueprint(api_route, url_prefix='/api') app.register_blueprint(web_route) register_extensions(app) return app app = create_app() db.create_all()
def create(): "Creates database tables from sqlalchemy models" print 'Connected to {}'.format(repr(db.engine.url)) if prompt_bool("Are you sure you want to create the tables?"): db.create_all() print 'Tables created'
def create_tables(): db.create_all()