[python]Flask Migrate

Flask Migrate advantage This is for easy update of the existing database, such as create a new column, create a new table, drop a table, revert previous database. With migrate, I do not need to do the db.create_all() anymore. A note on sqlite3, once a table is created you cannot insert column directly, need to … Continue reading [python]Flask Migrate

Advertisements

[python]Query object from table with Flask SQLAlchemy

The purpose of using SQLAlchemy is to avoid using SQL syntax, and Flask's extension of SQLAlchemy makes usage easier than the original SQLAlchemy. So here are two demonstrations to query every row and query one row with a condition.

[python] Flask SQLAlchemy insert data

On previous post it was demonstrated that creating database is easier with Flask SQLAlchemy than using SQLAlchemy itself. This post demonstrates how data can be inserted to existing database, and also to check if the tables exist before executing create_all(). create_all() does not re-create table if the table exists, the if statement is to demonstrate … Continue reading [python] Flask SQLAlchemy insert data

[python] Create database with flask-sqlalchemy

On previous post I have used a pure SQLAlchemy module to just create the database, this time I am using Flask_SQLAlchemy to do it, which makes the creation simpler. I will need to put in two configuration parameters: SQLALCHEMY_DATABASE_URI SQLALCHEMY_TRACK_MODIFICATIONS For the configuration I have put them in a config.py file. As usual you need … Continue reading [python] Create database with flask-sqlalchemy