-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_table.py
More file actions
48 lines (42 loc) · 1 KB
/
Copy pathcreate_table.py
File metadata and controls
48 lines (42 loc) · 1 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
import os
import psycopg2
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
DB_ENDPOINT = os.getenv('DB_ENDPOINT', '')
DB_USER = os.getenv('DB_USER', '')
DB_PASSWORD = os.getenv('DB_PASSWORD', '')
DB_PORT = os.getenv('DB_PORT', '')
conn = psycopg2.connect(f"""
host={DB_ENDPOINT}
user={DB_USER}
password={DB_PASSWORD}
port={DB_PORT}""")
conn.autocommit = True
cur = conn.cursor()
create_table_likes_statement = """
DROP TABLE IF EXISTS likes;
CREATE TABLE likes (
date VARCHAR,
tweet VARCHAR,
user_logo VARCHAR,
user_alias VARCHAR,
text VARCHAR,
media VARCHAR,
user_name VARCHAR,
location VARCHAR,
user_bio VARCHAR,
url VARCHAR,
likes BIGINT,
rts BIGINT,
user_follower_count BIGINT,
logo_user_quoted_tweet VARCHAR,
quoted_tweet_text VARCHAR,
user_alias_quoted VARCHAR,
user_name_quoted VARCHAR,
id BIGINT
);
"""
print('Dropping table and creating it again')
cur.execute(create_table_likes_statement)
print('Done')