def get_index(city): new_db = mysql_db() # q = new_db.execute("SELECT postal_code FROM `postal_codes` WHERE `city_name`='" + city + "' LIMIT 0, 1") q = new_db.execute("SELECT pindx17.index FROM `pindx17` WHERE city=\"" + city.upper() + "\" or region=\"" + city.upper() + "\" LIMIT 0, 1") # print(q) if q == None: return "Fail" for postal_code in q: return str(postal_code[0])
def get_index(city): new_db = mysql_db() # q = new_db.execute("SELECT postal_code FROM `postal_codes` WHERE `city_name`='" + city + "' LIMIT 0, 1") q = new_db.execute("SELECT pindx17.index FROM `pindx17` WHERE city=\"" + city.upper() + "\" or region=\"" + city.upper() + "\" LIMIT 0, 1") # print(q) if q == None: return "Fail" for postal_code in q: return str(postal_code[0])
def find_in_base(command): new_db = mysql_db() q = new_db.execute("SELECT response FROM responses WHERE command='" + command + "' AND CURRENT_TIMESTAMP - `responses`.`date` <= 86400") if q == None: return "" else: response = "" for (resp) in q: response += resp[0] return response
def find_in_base(command): new_db = mysql_db() q = new_db.execute("SELECT response FROM responses WHERE command='" + command + "' AND CURRENT_TIMESTAMP - `responses`.`date` <= 86400") if q == None: return "" else: response = "" for (resp) in q: response += resp[0] return response
def add_response(command, response): # print(command, response) db1 = mysql_db() q = db1.execute("DELETE FROM responses WHERE command='" + command + "'") # print(q) # db1.cursor.close() # db1.db.close() # db2 = mysql_db() q = db1.execute("INSERT INTO responses (command, response) VALUES ('" + command + "', '" + response + "')") # print(q) db1.db.commit() db1.cursor.close()
def add_response(command, response): # print(command, response) db1 = mysql_db() q = db1.execute("DELETE FROM responses WHERE command='" + command + "'") # print(q) # db1.cursor.close() # db1.db.close() # db2 = mysql_db() q = db1.execute("INSERT INTO responses (command, response) VALUES ('" + command + "', '" + response.replace('\\', '\\\\') + "')") #oh my god, this is awful!!! # print(q) db1.db.commit() db1.cursor.close()
def add_response(command, response): # print(command, response) db1 = mysql_db() q = db1.execute("DELETE FROM responses WHERE command='" + command + "'") # print(q) # db1.cursor.close() # db1.db.close() # db2 = mysql_db() q = db1.execute("INSERT INTO responses (command, response) VALUES ('" + command + "', '" + response.replace('\\', '\\\\') + "')") #oh my god, this is awful!!! # print(q) db1.db.commit() db1.cursor.close()
fromCity = sys.argv[1] origCity = sys.argv[2] weight = sys.argv[3] volume = sys.argv[4] value = sys.argv[5] from types import * #if type(fromCity) is UnicodeType: #fromCity = fromCity.decode("utf-8") #if type(toCity) is UnicodeType: #toCity = toCity.decode("utf-8") prices = [] db = mysql_db() def prepare_json(prices_list, site_id): d = { "site_id": site_id, "low_price": int(prices_list[0]), "high_price": int(prices_list[-1]), "prices": prices_list } return json.dumps(d) response = []
fromCity = sys.argv[1] origCity = sys.argv[2] weight = sys.argv[3] volume = sys.argv[4] value = sys.argv[5] from types import * #if type(fromCity) is UnicodeType: #fromCity = fromCity.decode("utf-8") #if type(toCity) is UnicodeType: #toCity = toCity.decode("utf-8") prices = [] db = mysql_db() def prepare_json(prices_list, site_id): d = {"site_id":site_id, "low_price":int(prices_list[0]), "high_price":int(prices_list[-1]), "prices":prices_list} return json.dumps(d) response = [] def get_index(city): new_db = mysql_db() # q = new_db.execute("SELECT postal_code FROM `postal_codes` WHERE `city_name`='" + city + "' LIMIT 0, 1") q = new_db.execute("SELECT pindx17.index FROM `pindx17` WHERE city=\"" + city.upper() + "\" or region=\"" + city.upper() + "\" LIMIT 0, 1") # print(q) if q == None: return "Fail" for postal_code in q: