Show Menu
Cheatography

Flask-SQLAlchemy Cheat Sheet (DRAFT) by

Simple help for using SQLAlchemy in Flask projects

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Flask-­SQL­Alchemy Column Types

Integer
an integer
String (size)
a string with a maximum length
Text
some longer unicode text
DateTime
date and time expressed as Python datetime object.
Float
stores floating point values
Boolean
stores a boolean value
PickleType
stores a pickled Python object
LargeB­inary
stores large arbitrary binary data
Example:
username = db.Col­umn(db.String(80)

Flask-­SQL­Alchemy Simple Example

from app import app
from flask.e­xt.sq­lal­chemy import SQLAlchemy
 
 
db = SQLAlchemy(app)
 
class YourClass:
Col1 = db.Column(db.Integer, args1)
 
...
def __init__(args):
...
def __repr__(self):
...
1 List of args in table below