Skip to content

Commit 7c682f4

Browse files
authored
Add files via upload
1 parent ab4e6af commit 7c682f4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

reviews.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
# We import the requests module which allows us to make the API call
21
#! /usr/bin/python3
2+
3+
# We import the requests module which allows us to make the API call
34
import json
45
import requests
5-
import mysql.connector
6+
import _mysql
67
import argparse
78
import urllib
89
import sys
910
import pprint
1011

12+
1113
from urllib.error import HTTPError
1214
from urllib.parse import quote
1315
from urllib.parse import urlencode
@@ -23,7 +25,7 @@
2325
BUSINESS_PATH = '/v3/businesses/'
2426

2527

26-
location = input("Enter Zip Code: ")
28+
location = input("Enter Location: ")
2729
search_limit = 1
2830

2931
def request(host, path, api_key, url_params=None):
@@ -116,18 +118,18 @@ def query_api(location):
116118

117119
print (bus_name + " ... adding to DB. ")
118120

119-
conn = mysql.connector.connect(user='root', password = '', host ='localhost', database ='yelp')
121+
conn = _mysql.connect(host ='localhost', user='shahk5', passwd = 'warmmuffins', db ='shahk5')
120122

121-
cursor = conn.cursor()
122-
123-
myquery = ("INSERT INTO reviews " "(bus_name, rating, text)" "VALUES (%s ,%s,%s)", (bus_name, user_rating, text))
123+
124124

125-
cursor.execute(*myquery)
125+
myquery = """INSERT INTO reviews(bus_name, rating, text) VALUES('%s', '%s', '%s')""" %(bus_name, user_rating, text)
126+
#+ bus_name +", "+ user_rating + "," + text +
127+
conn.query(myquery)
126128
conn.commit()
127129
print ("added.")
128130

129131

130-
cursor.close()
132+
131133
conn.close()
132134

133135

@@ -153,4 +155,4 @@ def main():
153155

154156

155157
if __name__ == '__main__':
156-
main()
158+
main()

0 commit comments

Comments
 (0)