Question: Python3 / Sqlite3 / json / Question Hello, I'm trying to inser data from an API weather site to a database in SQLIte3 . I'm

Python3 / Sqlite3 / json / Question

Hello, I'm trying to inser data from an API weather site to a database in SQLIte3 . I'm getting this error:

cur.executemany('INSERT INTO wdata values (?,?,?,?)',forecasts) ValueError: parameters are of unsupported type

here is an example how the data looks from the API :

"currently": { "time": 1509993277, "summary": "Drizzle", "icon": "rain", "nearestStormDistance": 0, "precipIntensity": 0.0089, "precipIntensityError": 0.0046, "precipProbability": 0.9, "precipType": "rain", "temperature": 66.1, "apparentTemperature": 66.31, "dewPoint": 60.77,

Here Is my code:

Python3 / Sqlite3 / json / Question Hello, I'm trying to inser

url 'https://api.darksky.net/forecast/e17c10c93f30ea8c4c6a4552b/'+str(latitude)+", "+str(longitude) res requests.get (url) read-res.json() 43 45 47 48 ID 0 temp-"[".format(read I currently'] ['temperature']) wind_speed-".format(read I'currently']['windSpeed']) humidity="{}", format ( read [ 'cu r rently' ] [ 'humidity' ] ) 50 51 52 53 54 forecasts [int(ID), float (wind_speed), float(temp), float (humidity)] #print ( forecasts) 56 57 58 59 60 61 62 63 64 65 cur conn.cursor() def create_table): cur.execute( 'CREATE TABLE IF NOT EXISTS wdata(ID INTEGER, wind_speed NUMERIC, temp NUMERIC, humidity NUMERIC)') def data_entry(): cur.executemany('INSERT INTO wdata values (?,7,?,7)',forecasts) conn.commit() 67 68 create table() data_entry() url 'https://api.darksky.net/forecast/e17c10c93f30ea8c4c6a4552b/'+str(latitude)+", "+str(longitude) res requests.get (url) read-res.json() 43 45 47 48 ID 0 temp-"[".format(read I currently'] ['temperature']) wind_speed-".format(read I'currently']['windSpeed']) humidity="{}", format ( read [ 'cu r rently' ] [ 'humidity' ] ) 50 51 52 53 54 forecasts [int(ID), float (wind_speed), float(temp), float (humidity)] #print ( forecasts) 56 57 58 59 60 61 62 63 64 65 cur conn.cursor() def create_table): cur.execute( 'CREATE TABLE IF NOT EXISTS wdata(ID INTEGER, wind_speed NUMERIC, temp NUMERIC, humidity NUMERIC)') def data_entry(): cur.executemany('INSERT INTO wdata values (?,7,?,7)',forecasts) conn.commit() 67 68 create table() data_entry()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!