-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_tables.py
More file actions
39 lines (34 loc) · 918 Bytes
/
create_tables.py
File metadata and controls
39 lines (34 loc) · 918 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
"""
This module creates the tables in the postgresql that will store the
data from Reddit (subreddits, submissions and comments).
"""
from db_connect import db, cur
cur.execute("""
CREATE TABLE main_subreddits
(
id VARCHAR(255) NOT NULL,
name TEXT NOT NULL,
title TEXT NOT NULL,
created INT NOT NULL
)
""")
cur.execute("""
CREATE TABLE main_submissions
(
id VARCHAR(255) NOT NULL,
subreddit_id VARCHAR(255) NOT NULL,
content TEXT
)
""")
cur.execute("""
CREATE TABLE main_comments
(
id VARCHAR(255) NOT NULL,
subreddit_id VARCHAR(255) NOT NULL,
submission_id VARCHAR(255) NOT NULL,
content TEXT
)
""")
db.commit()
cur.close()
db.close()