-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsqlInit.py
More file actions
40 lines (30 loc) · 734 Bytes
/
sqlInit.py
File metadata and controls
40 lines (30 loc) · 734 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
#run this code with command to init sql table
import os
import psycopg2
DATABASE_URL = os.environ['DATABASE_URL']
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
cur = conn.cursor()
try:
cur.execute('''CREATE TABLE messagelists
(num SERIAL,
time TEXT,
message TEXT,
userid TEXT,
token TEXT
);''')
conn.commit()
except:
print("faile to make messagelists table")
try:
cur.execute('''CREATE TABLE userdata
(chatid INT ,
status TEXT,
timesendpost TEXT,
channelid TEXT,
token TEXT,
idselected TEXT
);''')
conn.commit()
except:
print("faile to make userData table")
conn.close()