Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/green-blue-couchette/mini-project---weather-db-with-python

A Python program to retrieve weather data from OpenWeatherMap and store it in an SQLite database. Hands-on project to aid my learning and for my portfolio.
https://github.com/green-blue-couchette/mini-project---weather-db-with-python

databases hobby-project portfolio python sqlite

Last synced: 19 days ago
JSON representation

A Python program to retrieve weather data from OpenWeatherMap and store it in an SQLite database. Hands-on project to aid my learning and for my portfolio.

Awesome Lists containing this project

README

        

# About "Mini project - Weather DB with Python 3"
A simple personal project where I tie together some basic knowledge from Python 3 and SQLite databases, which I learned on my free time.

## What it is
A small command-line program that lets you search for a location, e.g. `Kvevlax, Finland`, and store its current weather info from OpenWeatherMap in an SQLite database. It also lets you view or delete the stored places and their weather data, afterwards.

## How to use
Download the `weatherdb.py` and `credentials.py` scripts to your machine.\
Run it using `python3 weatherdb.py` or `./weatherdb.py`. Make sure you fill the credentials file with your own OpenWeatherMap API key first.

If this is the first time you run `weatherdb.py`, enter the command `#clear` at the prompt to create the `.sqlite` database. Otherwise, you will get an error.

## Libraries and tools used
* Python 3 for the programming language, including the libraries `sqlite 3` for the database operations, and `urllib` and `json` for making REST API requests and parsing the responses.
* Visual Studio Code for writing the code
* [Postman](https://www.postman.com/) to get acquainted with OpenWeatherMap's REST API endpoint's responses
* [SQLite](https://www.sqlite.org/index.html) and the [DB Browser for SQLite](https://sqlitebrowser.org/) for the database
* [dbdiagram](https://dbdiagram.io/d) for designing the database diagram

### Database structure
![Database diagram 2024-08-08 19-58-19](https://github.com/user-attachments/assets/2d84b3cf-61c1-4c12-b738-e9f7a8b7982f)

## Screenshots
Demo – Searching for a location, e.g. `Köln`:
![Location search example output](https://github.com/user-attachments/assets/2fe9ab46-1824-41af-bbf5-ff5ecd6a17be)

Demo – Displaying all searched locations that got stored in the `weatherdb.sqlite` database – SQLite DB browser's contents vs `weatherdb.py`'s output:
![Python 3 output and SQLite DB example output](https://github.com/user-attachments/assets/d7b8cca7-0600-4450-acf6-84eab931deb4)