0

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?

mukund
  • 9
  • 6
  • Does this answer your question? [How to insert a pandas dataframe to an already existing table in a database?](https://stackoverflow.com/questions/38610723/how-to-insert-a-pandas-dataframe-to-an-already-existing-table-in-a-database) – buran Apr 19 '22 at 19:51
  • Possible duplicate: https://stackoverflow.com/questions/46407770/how-to-convert-a-json-file-to-an-sqlite-database – Bill Karwin Apr 19 '22 at 19:51

0 Answers0