def initdb():
    db.create_all()
    db.session.add(
        User(username="******", email="*****@*****.**", password="******"))
    db.session.add(
        User(username="******", email="*****@*****.**", password="******"))
    db.session.commit()
    print("Initialize the database.")
Exemple #2
0
def client():
    app.config.from_pyfile('{}/app/config/test.py'.format(cfg.BASE_DIR))
    client = app.test_client()

    with app.app_context():
        db.create_all()

    yield client
    os.unlink(app.config['DATABASE'])
 def setUp(self):
     TEST_DB = 'test_cardatabase.db'
     project_dir = os.path.dirname(os.path.abspath(__file__))
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config['DEBUG'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
         os.path.join(project_dir, TEST_DB)
     self.app = app.test_client()
     db.drop_all()
     db.create_all()
Exemple #4
0
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 25 14:52:17 2015

@author: Daniel
"""

from routes import db

#create database
db.create_all()

from routes import db
from models import *
import os

# create the database and the db table
#db.init_app(app)
db.create_all()

# insert data
db.session.add(User("admin", "admin", "*****@*****.**", "P@ssw0rd!"))
db.session.add(User("Nupur", "Patel", "*****@*****.**", "let-me-in"))

# commit the changes
db.session.commit()
from routes import app, db

if __name__ == '__main__':
    db.create_all() #pragma no cover
    app.run(debug=True) #pragma no cover