-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabase.sqlite
More file actions
43 lines (36 loc) · 970 Bytes
/
database.sqlite
File metadata and controls
43 lines (36 loc) · 970 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
import sqlite3
def create_database():
conn = sqlite3.connect('database.sqlite')
c = conn.cursor()
# Create table for User
c.execute('''
CREATE TABLE User (
id INTEGER PRIMARY KEY,
username TEXT NOT NULL,
password TEXT NOT NULL,
email TEXT NOT NULL UNIQUE
)
''')
# Create table for Podcast
c.execute('''
CREATE TABLE Podcast (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
description TEXT,
user_id INTEGER,
FOREIGN KEY(user_id) REFERENCES User(id)
)
''')
# Create table for Guest
c.execute('''
CREATE TABLE Guest (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
podcast_id INTEGER,
FOREIGN KEY(podcast_id) REFERENCES Podcast(id)
)
''')
conn.commit()
conn.close()
if __name__ == "__main__":
create_database()