Exemple #1
0
def main():
    from app.core import db
    if len(sys.argv) > 1:
        if sys.argv[1] == 'create':
            db.create_all()
        elif sys.argv[1] == 'drop':
            db.drop_all()
        elif sys.argv[1] == 'fill':
            db.populate()
        else:
            print_help()
    else:
        app.run()
Exemple #2
0
from os import path
from flask import Flask
from flask_security import current_user
from flask_session import Session
from app.core import db, security, mail

import app.models as models_sounds
from .site import mod_site
import app.admin.models_security as models_security
from .admin import mod_admin

app = Flask(__name__, static_folder='static')
app.config.from_pyfile('config.py')

Session(app)
mail.init_app(app)

db.init_app(app)
db.create_all(app=app)  # app=app weil sonst applicationbound error

security.init_app(app, models_security.user_datastore)

app.register_blueprint(mod_admin, url_prefix='/admin')
app.register_blueprint(mod_site)

app.jinja_env.globals.update(config=app.config)
app.jinja_env.globals.update(current_user=current_user)
app.jinja_env.globals.update(path=path)

# seed_security()
Exemple #3
0
data_movie = {'name': 'Transformers', 'genre': 'action', 'year': 2007}
data_movie_upd = {
    'name': 'Teenage Mutant Ninja Turtles',
    'genre': 'bad movie',
    'year': 2014
}

app = Flask(__name__, instance_relative_config=False)
app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL
app.config[
    'SQLALCHEMY_TRACK_MODIFICATIONS'] = False  # silence the deprecation warning

db.init_app(app)

with app.app_context():
    db.create_all()
    actor = Actor.create(**data_actor)
    print('created actor:', actor.__dict__, '\\n')

    movie = Movie.create(**data_movie)
    print('created movie:', movie.__dict__, '\\n')

    upd_actor = Actor.update(1, **data_actor_upd)
    print('updated actor:', upd_actor.__dict__, '\\n')

    upd_movie = Movie.update(1, **data_movie_upd)
    print('updated movie:', upd_movie.__dict__, '\\n')

    add_rels_actor = Actor.add_relation(1, upd_movie)
    movie_2 = Movie.create(**data_movie)
    add_more_rels_actor = Actor.add_relation(1, movie_2)
def refreshdb():
    """ Drop then reinitialize the database """
    db.drop_all()
    db.create_all()
    print(colored('The SQL database has been recreated!', 'green'))
def initdb():
    """ Create the SQL database. """
    db.create_all()
    print(colored('The SQL database has been created', 'green'))
Exemple #6
0
def reset_db():
    db.drop_all()
    db.create_all()
Exemple #7
0
def reset_db():
    db.drop_all()
    db.create_all()