Example #1
0
def remake_db(really=False):
    if not really:
        print("You should probably use 'python manage.py db upgrade' instead.")
        print("If you really want to use remake_db, provide option --really.")
        print("")
        print("(See https://flask-migrate.readthedocs.org/en/latest/ for"
              " details.)")
        return 0
    else:
        db.drop_all()
        db.create_all()
Example #2
0
def run_test_server():
    """Used by the phantomjs tests to run a live testing server"""
    # running the server in debug mode during testing fails for some reason
    app.config['DEBUG'] = False
    app.config['TESTING'] = True
    port = app.config['TESTSERVER_PORT']
    # Don't use the production database but a temporary test database.
    app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///test.db"
    db.drop_all()
    db.create_all()
    db.session.commit()

    # Add a route that allows the test code to shutdown the server, this allows
    # us to quit the server without killing the process thus enabling coverage
    # to work.
    app.add_url_rule('/shutdown', 'shutdown', shutdown,
                             methods=['POST', 'GET'])
    main.use_log_file_handler()

    app.run(port=port, use_reloader=False, threaded=True)

    db.session.remove()
    db.drop_all()
Example #3
0
 def setUp(self):
     """ create all tables """
     db.create_all()
 def setUp(self):
     db.create_all()
     self.create_log_types()
     self.create_user_agents()
     self.create_sample_data()
Example #5
0
## Use this module to create the database.
from app.main import db
from app.user import *
from app.product import *
from app.cart import *

if __name__ == "__main__":
	db.create_all()
Example #6
0
 def setUp(self):
     db.create_all()
     db.session.commit()
Example #7
0
 def setUp(self):
     db.create_all()
     db.session.commit()
     setup_default(db)
Example #8
0
################################################################################
# create_db.py                                                                 #
#                                                                              #
# Creates and initializes the database.                                        #
#                                                                              #
# Copyright 2016 University of Nevada, Reno                                    #
################################################################################

import os
import sys
sys.path.append(os.getcwd())

from app.main import db

if __name__ == '__main__':
    db.create_all()
Example #9
0
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from flask import send_file

from app import blueprint
from app.main import setup_app, db

env = os.getenv('BACKEND_ENV') or 'dev'
app = setup_app(env)
app.register_blueprint(blueprint)

app.app_context().push()
print("Creating new database: " + str(app.config['CREATE_DB']))
if 'CREATE_DB' in app.config:
    db.create_all()  # create everything


@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def index(path):
    res = 'index.html'
    print("path [" + path + "]")
    if path == 'styles.css' or path == 'bundle.js' or path == 'favicon.ico':
        res = path
    return send_file('../../static/' + res)


manager = Manager(app)

migrate = Migrate(app, db)
Example #10
0
def recreate_db():
    db.drop_all()
    db.create_all()
    db.session.commit()
Example #11
0
 def setUp(self):
     app.config.from_object('app.main.config.TestingConfig')
     self.app = app.test_client()
     with app.app_context():
         db.create_all()
Example #12
0
 def setUp(self):
     """ start testing with database up """
     db.create_all()
     db.session.commit()
Example #13
0
def create_db():
    """Creates the db tables."""
    db.create_all()