As the title indicates, how does one use python to elegantly access an API and parse and save the JSON contents onto a relational database (MYSQL) for later access?
Here, I saved the data onto a pandas object. But how do I create a mysql database, save the json contents onto it, and access the contents for later use?
# Libraries
import json, requests
import pandas as pd
from pandas.io.json import json_normalize
# Set URL
url = 'https://api-v2.themuse.com/jobs'
# For loop to
for i in range(100):
data = json.loads(requests.get(
url=url,
params={'page': i}
).text)['results']
data_norm = pd.read_json(json.dumps(data))
requests.get(<args>).json()['results']
instead ofjson.loads(requests.get(<args>).text)['results']
sqlite
, and python has built-in support docs.python.org/2/library/sqlite3.htmlpandas
here? Also, you are overwritingdata
each iteration of the loop.