import os from flask_script import Manager from werkzeug.security import generate_password_hash from gym7 import create_app, init_db from gym7.database import db from pony import orm import gym7.api.models from gym7.models import * app = create_app(os.environ.get('GYM_SETTINGS', 'config.Development')) manager = Manager(app) @manager.command def init_db(): orm.sql_debug(True) db.bind(app.config['DB_TYPE'], app.config['DB_STRING'], create_db=True) db.generate_mapping(create_tables=True) print("Database initialized") @manager.command def add_user(login, password): gym7.init_db(app) with orm.db_session: password = str(generate_password_hash(password)) user = User(login=login, password=password)
import os from gym7 import create_app, init_db app = create_app(os.environ.get('GYM_SETTINGS', 'config.Production')) init_db(app)