Skip to content
Flask-Alchemy is designed to work with SQLAlchemy default declarative_base, with powerful master-slave and seprated databases support.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
.gitignore
.travis.yml
Makefile
README.rst
flask_alchemy.py
requirements.txt
setup.py

README.rst

Flask-Alchemy

WIP

Flask-Alchemy is designed to work with SQLAlchemy default declarative_base, with powerful master-slave and separated databases support.

Meta Flask Wheel Status Latest Version Travis CI Status Coverage Status

Getting Started

Flask-Alchemy is designed to work with plain SQLAlchemy models, if describe it in code, a plain model should be something like:

from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class User(Base):
    __tablename__ = 'user'
    id = Column(Integer, primary_key=True)
    name = Column(String(20))

And then we can register the Base with Flask-Alchemy:

from your_project import app
from flask_alchemy import Alchemy

db = Alchemy(app)
db.register_base(Base)

With this db.register_base, your User module can query like:

baba = User.query.filter_by(name='baba').first()

Advanced Topics

Flask-Alchemy is more than that, it can bind each table to its own database, it can send the SELECT query to your slave databases.

You can’t perform that action at this time.