-
Notifications
You must be signed in to change notification settings - Fork 494
/
queries.py
35 lines (33 loc) · 1.24 KB
/
queries.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
create_business_schema = """CREATE SCHEMA IF NOT EXISTS yelp;"""
create_business_table = """
CREATE TABLE IF NOT EXISTS yelp.business (
business_id varchar PRIMARY KEY,
business_name varchar,
image_url varchar,
url varchar,
review_count int,
categories varchar,
rating float,
latitude float,
longitude float,
price varchar,
location varchar,
phone varchar
);
"""
insert_business_table = """INSERT INTO yelp.business VALUES ('{}', '{}', '{}', '{}', {}, '{}', {}, {}, {}, '{}', '{}', '{}')
ON CONFLICT (business_id)
DO UPDATE SET
business_id = EXCLUDED.business_id,
business_name = EXCLUDED.business_name,
image_url = EXCLUDED.image_url,
url = EXCLUDED.url,
review_count = EXCLUDED.review_count,
categories = EXCLUDED.categories,
rating = EXCLUDED.rating,
latitude = EXCLUDED.latitude,
longitude = EXCLUDED.longitude,
price = EXCLUDED.price,
location = EXCLUDED.location,
phone = EXCLUDED.phone;
"""