Skip to content

Web interface for a portfolio of projects.

Notifications You must be signed in to change notification settings

danpoynor/portfolio-with-sqlalchemy

Repository files navigation

Python Portfolio with Flask and SQLAlchemy

Description

Web interface for a portfolio of projects.

This demo app uses my knowledge of CSV, File I/O, and database ORMs to create a portfolio management system which users can easily interact with to store project data. The data is cleaned from a CSV file with default data before it's added to an SQLite database file named projects.db. All interactions with the records use ORM methods for viewing records, creating records, editing records, and deleting records.


Run the app

Clone this repo then cd portfolio-with-sqlalchemy.

Assuming you have Python3 installed on a MacOS, run these commands (or something similar):

python3 -m venv env
source env/bin/activate
pip install -r requirements.txt

👉 Rename the .env.example file to .env and edit for your local environment if needed:

cp .env.example .env

Then run the app:

python app.py

You should then be able to view the app at http://127.0.0.1:8000/

When done running the app, you can deactivate the virtual environment by running deactivate.


What I Learned About / Feature Highlights

  • Loading default data from a CSV file projects.csv.
  • Cleaning data and formatting before storing in a SQLite database projects.db file.
  • Using Flask-SQLAlchemy to connect and interact with the database.
  • Using Jinja templating and template inheritance.
  • Using one form input template for both create and edit views.
  • Implementing CRUD functionality.
  • Catching 404 errors and display a custom error message.
  • Catching 500 errors and display a custom error message.
  • Using python-dotenv load_dotenv() to configure Flask dev environment from a .env file.
  • Using Flask Context Processors to inject variables automatically into templates.
  • Using Pylint to analyze the code for errors and potential problems.

Technologies Used

  • Python: Programming language
  • Flask: Flexible and popular web development microframework.
  • Jinja: Full featured, fast, expressive, extensible templating engine for Python.
  • SQLAlchemy: Python SQL toolkit and Object Relational Mapper (ORM) that gives application developers the full power and flexibility of SQL.
  • SQLite: Most used database engine in the world.
  • Python-dotenv: Reads key-value pairs from a .env file and can set them as environment variables. It helps in the development of applications following the 12-factor principles.
  • Pylint
  • CSV file format used for storing imported and exported data in a human readable including a header row of field names.

Screenshot of Index Page

Expand/Collapse Screenshot of Python Portfolio with Flask and SQLAlchemy by Dan Poynor

Potential TODO's