This Python script fetches and stores air quality data from different cities around the world into an SQLite database.
sqlite3timerequestsjsondatetime
Before running the script, make sure you have a config.json file with the AirVisual API key:
```json { "airvisual_api_key": "YOUR_API_KEY" } ```
- Initialize SQLite database with a specific schema.
- Fetch air quality data from an API.
- Store the fetched data into the SQLite database.
- Various functions for viewing the database.
- Supports rate limiting and retries.
Initializes an SQLite database with a specific table schema for storing air quality data.
Fetches air quality data for a specific location from the API. The function returns this data as a dictionary. It also handles various types of API errors and rate limiting.
Takes a dictionary containing air quality data and stores it in the SQLite database.
A utility function that takes a list of database rows and pretty-prints them to the console.
These functions are responsible for displaying the database contents. They allow the user to view data sorted by different attributes, such as date, AQI, temperature, and humidity.
print_database()print_sorted_by_date()print_sorted_by_aqi()print_sorted_by_temp()print_sorted_by_humidity()print_sorted_by_state_and_city()
Deletes all records from the database. Use this function with caution as it will remove all stored data.