def init_database():
    """This function checks to see if the database exists, and if not, generates the tables."""
    database.init(DATABASE_NAME)
    database.connect()
    database.execute_sql('PRAGMA foreign_keys = ON')
    if not database.table_exists([Customer]):
        database.create_tables([Customer])
    database.close()
 def setUp(self):
     """Defines starting test database used for function testing."""
     self.starting_db = [(1, 'Bob', 'Bobbo', '12 Green St', '1112223344',
                          '*****@*****.**', False, 85000),
                         (2, 'Jane', 'Janeo', '1550 Red Rd', '1118675309',
                          '*****@*****.**', True, 150000),
                         (5, 'Wilson', 'Volleyball', '1 Castaway Island', '0000000000',
                          '*****@*****.**', True, 0)
                         ]
     database.init(TEST_DATABASE)
     database.connect()
     database.execute_sql('PRAGMA foreign_keys = ON')
     database.create_tables([Customer])
     with database.transaction():
         Customer.delete().execute()
         Customer.insert_many(self.starting_db, fields=[Customer.customer_id, Customer.name,
                                                        Customer.lastname, Customer.home_address,
                                                        Customer.phone_number,
                                                        Customer.email_address,
                                                        Customer.active_status,
                                                        Customer.credit_limit
                                                        ]).execute()
     database.close()