Question
1.1, 1.2 Creating/Reading Database Data Using the database structure created in the previous assignment, populate the database with some information. Directions: Gather weather data from
1.1, 1.2 Creating/Reading Database Data Using the database structure created in the previous assignment, populate the database with some information. Directions: Gather weather data from at least two different counties for a range of 30 days Import this data into your program Write this data to your database tables in the Location and Precipitation tables Submit your working program and database file for grading. Please ensure when you build your program, your database file exists in the same directory as your program for ease of grading. This assignment is worth 15 points
HERE IS THE CODE I NEED HELP WITH
/////////////////////////////////////////////////////////////////////
import sqlite3 # Create a connection to the database conn = sqlite3.connect('weather_tracking.db') # Create the Location table conn.execute('CREATE TABLE Location (county TEXT PRIMARY KEY, state TEXT)') # Create the Precipitation table conn.execute('CREATE TABLE Precipitation (location TEXT REFERENCES Location(county), date TEXT, precipitation FLOAT, precip_type TEXT)') # Output the table information cursor = conn.cursor() cursor.execute("SELECT name FROM sqlite_master WHERE type='table';") print(cursor.fetchall()) cursor.execute("PRAGMA table_info(Location);") print(cursor.fetchall()) cursor.execute("PRAGMA table_info(Precipitation);") print(cursor.fetchall()) # Close the connection to the database conn.close()
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