Beispiel #1
0
def create_app(config_name):
    ''' creates app and registers blueprints '''
    app = Flask(__name__)
    db_init()
    JWTManager(app)
    app.register_blueprint(VERSION_ONE)
    app.config['SECRET_KEY'] = '7d441f27d441f27567d441f2b6176a'
    app.config.from_object(APP_CONFIG[config_name])
    return app
Beispiel #2
0

if __name__ == "__main__":

    PARSER = argparse.ArgumentParser(
        description='Database management tool for flocka_records')

    PARSER.add_argument('-a',
                        '--action',
                        metavar='[migrate|truncate|seed]',
                        help='Database action',
                        choices={'migrate', 'truncate', 'seed'},
                        const='migrate',
                        nargs='?')

    ARGS = PARSER.parse_args()

    # open database connection
    BASE_CONN = db_init()

    if ARGS.action == 'migrate':
        migrate()
    elif ARGS.action == 'truncate':
        truncate()
    elif ARGS.action == 'seed':
        seed()
    else:
        pass
    BASE_CONN.commit()
# close connection here
Beispiel #3
0
 def __init__(self):
     self.connection = db_init()
     self.cursor = self.connection.cursor(cursor_factory=RealDictCursor)