'How to transfer JSON data to sqlite in Python

I have fetched some data from an API using pandas. That is JSON format. I want to transfer this data to a sqlite database called "pitch.db" so I can run some SQL queries on it.

This is what I have so far:

import pandas as pd
import requests
import sqlite3
import json

url = "https://baseballsavant.mlb.com/gf?game_pk=635886"
df = pd.read_json(url, orient='index')
# print(df) # This prints the data and is working
conn = sqlite3.connect('pitch.db')
c = conn.cursor()

Please tell me how can I do so?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source