forked from HarshShah1997/Shopping-Cart
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabase.py
More file actions
51 lines (39 loc) · 877 Bytes
/
Copy pathdatabase.py
File metadata and controls
51 lines (39 loc) · 877 Bytes
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
import sqlite3
#Open database
conn = sqlite3.connect('database.db')
#Create table
conn.execute('''CREATE TABLE users
(userId INTEGER PRIMARY KEY,
password TEXT,
email TEXT,
firstName TEXT,
lastName TEXT,
address1 TEXT,
address2 TEXT,
zipcode TEXT,
city TEXT,
state TEXT,
country TEXT,
phone TEXT
)''')
conn.execute('''CREATE TABLE categories
(categoryId INTEGER PRIMARY KEY,
name TEXT
)''')
conn.execute('''CREATE TABLE products
(productId INTEGER PRIMARY KEY,
name TEXT,
price REAL,
description TEXT,
image TEXT,
stock INTEGER,
categoryId INTEGER,
FOREIGN KEY(categoryId) REFERENCES categories(categoryId)
)''')
conn.execute('''CREATE TABLE kart
(userId INTEGER,
productId INTEGER,
FOREIGN KEY(userId) REFERENCES users(userId),
FOREIGN KEY(productId) REFERENCES products(productId)
)''')
conn.close()