-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.py
More file actions
71 lines (61 loc) · 1.74 KB
/
create.py
File metadata and controls
71 lines (61 loc) · 1.74 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import sqlite3
if __name__ == '__main__':
connection = sqlite3.connect('proj4.db')
cursor = connection.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS
users(
username TEXT PRIMARY KEY,
password TEXT NOT NULL
)""")
cursor.execute("""CREATE TABLE IF NOT EXISTS
books(
isbn TEXT PRIMARY KEY,
btitle TEXT,
author TEXT,
published TEXT,
bdescription TEXT
)""")
cursor.execute("""CREATE TABLE IF NOT EXISTS
games(
gid INTEGER PRIMARY KEY,
gtitle TEXT,
publisher TEXT,
developer TEXT,
grelease TEXT,
gdescription TEXT
)""")
cursor.execute("""CREATE TABLE IF NOT EXISTS
movies(
mid INTEGER PRIMARY KEY,
mtitle TEXT,
director TEXT,
mrelease TEXT,
mdescription TEXT
)""")
cursor.execute("""CREATE TABLE IF NOT EXISTS
userbooks(
username TEXT,
isbn TEXT,
rating INTEGER,
FOREIGN KEY(username) REFERENCES users(username),
FOREIGN KEY(isbn) REFERENCES books(isbn)
)""")
cursor.execute("""CREATE TABLE IF NOT EXISTS
usergames(
username TEXT,
gid INTEGER,
rating INTEGER,
PRIMARY KEY (username, gid)
FOREIGN KEY(username) REFERENCES users(username),
FOREIGN KEY(gid) REFERENCES games(gid)
)""")
cursor.execute("""CREATE TABLE IF NOT EXISTS
usermovies(
username TEXT,
mid INTEGER,
rating INTEGER,
PRIMARY KEY (username, mid)
FOREIGN KEY(username) REFERENCES users(username),
FOREIGN KEY(mid) REFERENCES movies(mid)
)""")
cursor.close()