def run(): # Data to initialize database with PEOPLE = [{ 'fname': 'Doug', 'lname': 'Farrell' }, { 'fname': 'Kent', 'lname': 'Brockman' }, { 'fname': 'Bunny', 'lname': 'Easter' }] # Delete database file if it exists currently if not os.path.exists('people.db'): # Create the database db.create_all() # Iterate over the PEOPLE structure and populate the database for person in PEOPLE: p = Person(lname=person['lname'], fname=person['fname']) db.session.add(p) db.session.commit()
def setUp(self): self.test_client = infinote_app.test_client() db.create_all()
from app.config import db from app.models import Account from lib import password_encrypt db.drop_all() db.create_all() account1 = Account(first_name='Kristopher Matthew', last_name='De Jesus', username='******', email='*****@*****.**', mobile='09167312622', password=password_encrypt('kristopher@23'), role='it') account2 = Account(first_name='Katherine', last_name='Domingo', username='******', email='*****@*****.**', mobile='09174167279', password=password_encrypt('Homestuck1998'), role='admin') db.session.add(account1) db.session.add(account2) db.session.commit()
def init_db(): db.create_all()