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
34import json
45import requests
5- import mysql . connector
6+ import _mysql
67import argparse
78import urllib
89import sys
910import pprint
1011
12+
1113from urllib .error import HTTPError
1214from urllib .parse import quote
1315from urllib .parse import urlencode
2325BUSINESS_PATH = '/v3/businesses/'
2426
2527
26- location = input ("Enter Zip Code : " )
28+ location = input ("Enter Location : " )
2729search_limit = 1
2830
2931def 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
155157if __name__ == '__main__' :
156- main ()
158+ main ()
0 commit comments