-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_reset.py
More file actions
53 lines (36 loc) · 1.51 KB
/
database_reset.py
File metadata and controls
53 lines (36 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Author: Reid Moline
'''
This file is used to revert the database to my original configuration by regenerating all tables by dropping them, creating them, and refiling them using their respective code
This will delete all recorded transactions and also empty the reconcile database. Serves as a hard reset of the database.
'''
import sqlite3
from employees import create_filled_employees_table
from customers import create_filled_customers_table
from transactions import create_empty_transactions_table
from serialization import create_filled_serialization_table
from products import create_filled_products_table
from reconcile import create_empty_reconcile_table
def drop_all():
'''
Function that drops all tables in the database bikeshop.sqlite
Parameters: None
Returns: None
'''
connection = sqlite3.connect('bikeshop.sqlite')
cursor = connection.cursor()
cursor.execute('PRAGMA foreign_keys = ON;')
cursor.execute("DROP TABLE IF EXISTS Reconcile;")
cursor.execute("DROP TABLE IF EXISTS Transactions;")
cursor.execute("DROP TABLE IF EXISTS Serialization;")
cursor.execute("DROP TABLE IF EXISTS Customers;")
cursor.execute("DROP TABLE IF EXISTS Employees;")
cursor.execute("DROP TABLE IF EXISTS Products;")
connection.commit()
connection.close()
drop_all()
create_empty_transactions_table()
create_empty_reconcile_table()
create_filled_employees_table()
create_filled_customers_table()
create_filled_products_table()
create_filled_serialization_table()