-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
43 lines (39 loc) · 951 Bytes
/
setup.py
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
'''
Setup of Foodstitute
'''
import settings
import model
import argparse
from settings import USER
def main():
'''
Main function of setup.py
It fills the tables with products of CATEGORIES in settings.py
Arguments:
Pass {string}: password of foodstitute
'''
# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument(
"Pass",
help="Password of the SQL DB foodstitute for the account" +
USER
)
# Get args
args = parser.parse_args()
# Define password
Pass = args.Pass
# Connect to DB
db = model.DataBase(Pass)
# Drop Tables if exist
db.drop_Products()
# Create Tables
db.create_tables()
for category in settings.CATEGORIES:
db.feed_database(model.Category(category))
# Commit changes
db.connection.commit()
# Finally close connection
db.connection.close()
if __name__ == "__main__":
main()