-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbsetup.py
37 lines (31 loc) · 810 Bytes
/
dbsetup.py
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
import psycopg2 as db
import json
with open('config.json', 'r') as f:
config = json.load(f)
conn = db.connect(user=config['dbuser'], database=config['dbname'], host=config['dbhost'], password=config['dbpass']);
cur = conn.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS uber
(
city TEXT,
lat FLOAT (8),
lng FLOAT (8),
eta INTEGER,
time TIMESTAMP WITH TIME ZONE NOT NULL,
holiday BOOLEAN,
PRIMARY KEY (lat, lng, time)
);""")
print "Created table 'uber' successfully!\n"
cur.execute("""CREATE TABLE IF NOT EXISTS lyft
(
city TEXT,
lat FLOAT (8),
lng FLOAT (8),
eta INTEGER,
time TIMESTAMP WITH TIME ZONE NOT NULL,
holiday BOOLEAN,
PRIMARY KEY (lat, lng, time)
);""")
print "Created table 'lyft' successfully!\n"
conn.commit()
cur.close()
conn.close()