I'm trying to validate new entries in a MySQL table by sending a GET request to the ZipCodeAPI (http://www.zipcodeapi.com/API). The API returns a json if the entry is valid. For new entries being inserted into the table, the API should verify that the entry in the postal_code column is valid. How would I allow the API to take in any possible zip code from the column postal_code in the table? Also, how would I test if the json is valid? Is there a function I could call that would determine if a json object is returned?
The code is in Python.
import requests
import mysql.connector
import json
dbconnect= mysql.connector.connect(user= 'root', database= 'contacts')
cursor = dbconnect.cursor()
url= "http://www.zipcodeapi.com/rest/QPIGMAfa0CmeyWWp0bum6rk3K6jdhK57zOOmo3xpFTDeQzERL8dRAyVlEeyWYE3x/info.json/06226/degrees"
response= requests.get(url)
data= jsonloads(response.content)
query= cursor.execute("INSERT INTO customer "
"(id, ContactHash, NewContactHash, name, address1, address2, address3, city, country_code, country_code_iso2, state_province, postal_code, email_address, status, phone, CardCode, created_at, updated_at)
"VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)")
rows= cursor.fetchall()
for row in rows:
json= response.json()
if (json):
print json
else:
print "Invalid zip code. Please try again."
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I am trying to get data from online database(MySql) through json and want to display it as a ListViewWhat I've done so far :
I have a file which is part of an export out of an ERP System,The content of the file is a mixture of csv and fixed text
this is POST table ,if i enter the record in POST table simultaneously the multiple image have to upload into the POST_Gallery tableplease help me this
This question already has an answer here: