#!/usr/bin/env python3 ''' Building the default database and populating it. ''' import random from model import DB, Donor, Donation # pylint: disable = C0103 DB.connect() # This line will allow you "upgrade" an existing database by # dropping all existing tables from it. DB.drop_tables([Donor, Donation]) DB.create_tables([Donor, Donation]) alice = Donor(name="Alice") alice.save() bob = Donor(name="Bob") bob.save() charlie = Donor(name="Charlie") charlie.save() donors = [alice, bob, charlie] for x in range(30): Donation(donor=random.choice(donors), value=random.randint(100, 10000)).save()
#!/usr/bin/env python3 # Russell Felts # Flask To Do Activity 01 """ Scripts to run to set up our database """ from datetime import datetime from passlib.hash import pbkdf2_sha256 from model import DB, User, Task # Create the database tables for our model DB.connect() DB.drop_tables([User, Task]) DB.create_tables([User, Task]) Task(name="Do the laundry.").save() Task(name="Do the dishes.", performed=datetime.now()).save() User(name="admin", password=pbkdf2_sha256.hash("password")).save() User(name="bob", password=pbkdf2_sha256.hash("bobbob")).save()