Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started