I'm trying to insert data from a web API into my database (I am using sqlite3 on python 3.7.2) and I can't find any tutorials on how do to so. So far all my code is:
import requests, sqlite3
database = sqlite3.connect("ProjectDatabase.db")
cur = database.cursor()
d = requests.get("http://ergast.com/api/f1/2019/drivers")
I'm aiming to get the names and driver numbers of each driver and insert them all into a table called Drivers. (I'm also using more APIs with more tables, but if I figure out how to do one then the rest should be fine.) I assume I have to do something like
cur.execute('''INSERT INTO Drivers VALUES(?,?), (driverName, driverNumber)
''')
but I'm struggling to figure out how to insert the data straight into the table from the website. Does anyone know how to do this? Thanks
request -> parse -> insertat what point do you struggle?