Skip to content

recrsn/flask-sqlalchemy-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask SQLAlchemy Starter

Bare minimum starter template using Flask and SQLAlchemy.

Installation

Requirements

  • python 3.6 +
  • Pipenv for dependency management

Usage

  1. Clone this repository
  2. Copy .env.example to .env and modify the required values.
  3. Rename the flask_sqlalchemy_starter folder to your package name.
  4. Add/remove models
  5. Create migrations using flask db migrate
  6. Apply migrations to database using flask db upgrade
  7. Run tests with pytest -v tests

Configuring database

You can use any SQLAlchemy compatible URI string for the database. By default, the template uses a SQLite database.

To use a different database like Postgres, edit the DATABASE_URI accordingly and install the appropriate python package to connect to the DB.

Postgres

  1. Run pipenv install psycopg2
  2. Edit DATABASE_URI to postgres://<user>:<password>@<host>:5432/<database>

MySQL

  1. Run pipenv install mysql-connector
  2. Edit DATABASE_URI to mysql://<user>:<password>@<host>:3306/<database>

About

Bare minimum starter template using Flask and SQLAlchemy.

Topics

Resources

Stars

Watchers

Forks