https://github.com/ejw-data/sqlalchemy-flask-api-weather
SQLite Database accessed with SQLAlchemy to perform analysis and create Flask API of the data
https://github.com/ejw-data/sqlalchemy-flask-api-weather
flask pandas python sqlalchemy sqlite
Last synced: 3 months ago
JSON representation
SQLite Database accessed with SQLAlchemy to perform analysis and create Flask API of the data
- Host: GitHub
- URL: https://github.com/ejw-data/sqlalchemy-flask-api-weather
- Owner: ejw-data
- Created: 2019-10-26T15:23:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-02T06:18:17.000Z (over 3 years ago)
- Last Synced: 2025-03-15T16:44:29.892Z (over 1 year ago)
- Topics: flask, pandas, python, sqlalchemy, sqlite
- Language: Jupyter Notebook
- Homepage:
- Size: 1010 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sqlalchemy-flask-api-weather
Author: Erin James Wills, ejw.data@gmail.com

Photo by [NASA](https://unsplash.com/@nasa?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/weather?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)
## Overview
The purpose of this repo is to become familiarized with SQLAlchemy's Object Relational Mapper (ORM). To do this I will be using a SQLite database that has two tables about Hawaii weather (measurements and stations). The code associated with this project can be found in the analysis folder within a jupyter notebook named `climate_analysis.ipynb`. In addtion to analyzing the data, a Flask API was created that connects to the database and accepts five different API requests - three of the requests return a predefined query result but the other two API's allow for the user to include one or two user inputs that are used within the API request as database filters.
## Technologies
* Python
* Pandas
* SQLAlchemy
* Flask
* SQLite
## Data Source
Dataset generated by Trilogy Education Services. Origins beyond this is unknown.
## Setup and Installation
1. Environment needs the following:
* Python 3.6+
* pandas
* flask
* sqlalchemy.ext.automap
* sqlalchemy.orm
* datetime
* numpy
1. Activate your environment
1. Clone the repo to your local machine
1. Start Jupyter Notebook within the environment from the repo
1. Run `climate_analysis.ipynb` to test connections and queries
1. To run the flask app:
* In terminal, navigate to the top-level repo folder
* Activate your environment
* In terminal run: `python app.py`
* The routes that can be used are listed on the page.
## Examples

Fig.1 - API route options displayed in a browser

Fig.2 - API results returning a single day's precipation and temperature measurements

Fig.3 - Matplotlib histogram of temperatures returned from a date range query

Fig.4 - Matplotlib stacked area chart of temperatures returned from a date range query