Answered step by step
Verified Expert Solution
Link Copied!

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:

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago