Adds SQLAlchemy support to Flask

Overview

Flask-SQLAlchemy

Flask-SQLAlchemy is an extension for Flask that adds support for SQLAlchemy to your application. It aims to simplify using SQLAlchemy with Flask by providing useful defaults and extra helpers that make it easier to accomplish common tasks.

Installing

Install and update using pip:

$ pip install -U Flask-SQLAlchemy

A Simple Example

from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///example.sqlite"
db = SQLAlchemy(app)


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String, unique=True, nullable=False)
    email = db.Column(db.String, unique=True, nullable=False)


db.session.add(User(username="Flask", email="[email protected]"))
db.session.commit()

users = User.query.all()

Contributing

For guidance on setting up a development environment and how to make a contribution to Flask-SQLAlchemy, see the contributing guidelines.

Donate

The Pallets organization develops and supports Flask-SQLAlchemy. In order to grow the community of contributors and users, and allow the maintainers to devote more time to the projects, please donate today.

Links

Comments
  • Document how to use plain SQLAlchemy models with the Flask-SQLAlchemy session

    Document how to use plain SQLAlchemy models with the Flask-SQLAlchemy session

    The application I was writing required that I have models that were portable (not just for use with Flask), but I still wanted to be able to take advantage of the sessions that Flask-SQLAlchemy provided.

    It would be nice if it were documented somewhere that, if you are willing to forego some of the convenience methods on the Model (like Model.query), then you can use standard SQLAlchemy models with the Flask-SQLAlchemy session.

    Incidentally this approach also helps with avoiding circular imports when passing the SQLAlchemy() instance, db, around to each model.

    Here is an example:

    # models.py
    
    from sqlalchemy import Column, Integer, String
    from sqlalchemy.ext.declarative import declarative_base
    
    Base = declarative_base()
    
    class User(Base):
        __tablename__ = 'users'
    
        id = Column(Integer, primary_key=True)
        name = Column(String(50), unique=True)
        email = Column(String(120), unique=True)
    
        def __init__(self, name=None, email=None):
            self.name = name
            self.email = email
    
        def __repr__(self):
            return '<User %r>' % (self.name)
    
    # app.py
    
    from flask import Flask
    from models import Base, User
    from flask_sqlalchemy import SQLAlchemy
    
    app =  Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
    db = SQLAlchemy(app)
    
    @app.before_first_request
    def setup():
        # Recreate database each time for demo
        Base.metadata.drop_all(bind=db.engine)
        Base.metadata.create_all(bind=db.engine)
        db.session.add(User('Bob Jones', '[email protected]'))
        db.session.add(User('Joe Quimby', '[email protected]'))
        db.session.commit()
    
    @app.route('/')
    def root():
        users = db.session.query(User).all()
        return u"<br>".join([u"{0}: {1}".format(user.name, user.email) for user in users])
    
    if __name__ == '__main__':
        app.run('127.0.0.1', 5000) 
    
    opened by dmckeone 25
  • Fix #26 Use unique MetaData object for each bind

    Fix #26 Use unique MetaData object for each bind

    An InvalidRequestError occurs when subclassing db.Model with two objects that have the same __tablename__ but different __bind_key__.

    sqlalchemy.exc.InvalidRequestError: Table 'users' is already defined for
    this MetaData instance.  Specify 'extend_existing=True' to redefine
    options and columns on an existing Table object.
    

    This could happen, for example, if you had a users table in two different databases that you needed to access. This patch creates a unique MetaData object for each bind_key which stops this error from happening and allows access to tables with the same name in different databases. It also includes a test to verify the error is fixed.

    opened by ghost 22
  • Please release a maintenance release.

    Please release a maintenance release.

    Last release was Oct 15, 2015.

    A few critical fixes are needed specifically 3fec753592.

    Would it be possible to get a 2.2 release so our requirements file can use a version instead of a git version?

    opened by splbio 21
  • "Fix for AttributeError: 'SessionMaker' object has no attribute '_model_changes' when using fixture to load fixtures"

    Hi,

    I encountered the same error as this (scenario is also stated in the link): http://flask.pocoo.org/mailinglist/archive/2011/3/6/flask-sqlalchemy-and-fixtures/.

    Thanks

    opened by jpanganiban 19
  • TypeError: can't apply this __setattr__ to DefaultMeta object

    TypeError: can't apply this __setattr__ to DefaultMeta object

    I don't know where this comes from. I have a small project where all versions are pinned and the Flask app runs in a Docker container. I just made an unrelated changes with the same versions and get this error. Does this look familiar?

    Expected Behavior

    Just running without crashes

    from flask_sqlalchemy import SQLAlchemy
    
    db = SQLAlchemy()
    

    Actual Behavior

    Crashes

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 716, in __init__
        self.Model = self.make_declarative_base(model_class, metadata)
      File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 798, in make_declarative_base
        model.query_class = self.Query
      File "/usr/local/lib/python3.8/site-packages/sqlalchemy/ext/declarative/api.py", line 79, in __setattr__
        _add_attribute(cls, key, value)
      File "/usr/local/lib/python3.8/site-packages/sqlalchemy/ext/declarative/base.py", line 802, in _add_attribute
        type.__setattr__(cls, key, value)
    TypeError: can't apply this __setattr__ to DefaultMeta object
    
    

    Environment

    • Python version: Python 3.8.4 (Docker python:3.8-slim-buster)
    • Flask-SQLAlchemy version: flask-sqlalchemy==2.4.1
    • SQLAlchemy version: sqlalchemy==1.3.13
    opened by MartinThoma 18
  • Support additional SQLAlchemy parameters.

    Support additional SQLAlchemy parameters.

    I found some SQLAlchemy parameters are helpful when we have unreliable network connectivity between applications and database.

    • creator helps to create custom DBAPI connections.
    • echo_pool will log all check-ins/outs of the pool.
    • pool_pre_ping tests connections for linveness upon each checkout.
    • pool_reset_on_return allows to override default behavior upon return.

    By default, all those options are turned off (or following the default behavior in SQLAlchemy) for backward compatibility.

    For more information about the parameters, please refer to the following official SQLAlchemy documentation: http://docs.sqlalchemy.org/en/latest/core/engines.html#engine-creation-api

    opened by yangbaepark 18
  • make it possible to pass additional options to create_engine

    make it possible to pass additional options to create_engine

    I needed to pass in an isolation_level parameters to the create_engine call. I did it like this:

    https://github.com/gromgull/flask-sqlalchemy/commit/689c90c48949dc4c020f16550576c517d2fb5230

    (on top of the 1.0 tag since that's what we used, but I can make a pull-request with it applied to HEAD if you want)

    config 
    opened by gromgull 18
  • Model with tablename of reflected table does not have table assigned

    Model with tablename of reflected table does not have table assigned

    Just updated and my full application, working previously, broke down on setting the model due to the update (https://github.com/mitsuhiko/flask-sqlalchemy/pull/541). I believe it might be a problem with this new primary key detection thing, which I'm not sure I get the point of. The previously-fine code is thus:

    from flask import Flask
    from flask_sqlalchemy import SQLAlchemy
    
    app = Flask(__name__)
    db = SQLAlchemy(app)
    db.reflect()
    
    class Country(db.Model):
        __tablename__ = 'd_country'
    

    Resulting in:

    InvalidRequestError: Class <class 'app.models.Country'> does not have a __table__ or __tablename__ specified and does not inherit from an existing table-mapped class.

    I'd be willing to bet that the update didn't take db.reflect() into account. I'm rolling back unless there's something else I can do, but I'd rather not have to do a declared_attr on all my tables just for this thing.

    bug tablename 
    opened by flipperbw 17
  • Issue using NullPool poolclass in MySQL

    Issue using NullPool poolclass in MySQL

    I am using version 2.4.1. I am trying to set my poolclass to NullPool by passing that option into my engine options like so:

    from sqlalchemy.pool import NullPool
    SQLALCHEMY_ENGINE_OPTIONS = {"poolclass":NullPool}
    

    That is working as expected and the poolclass is being set. However I am getting the following error when running:

    TypeError: Invalid argument(s) 'pool_size' sent to create_engine(), using configuration AuroraMySQLDataAPIDialect/NullPool/Engine.  Please check that the keyword arguments are appropriate for this combination of components.
    

    The pool_size needs to NOT be set in order to use NullPool. This seems to be happening because the pool_size is being set to 10. I did some digging and found it was being set in apply_driver_hacks:

            if sa_url.drivername.startswith('mysql'):
                sa_url.query.setdefault('charset', 'utf8')
                if sa_url.drivername != 'mysql+gaerdbms':
                    options.setdefault('pool_size', 10)
                    options.setdefault('pool_recycle', 7200)
    

    If I comment out those last 3 lines and run my code, the pool size doesn't get set and everything works as expected.

    But I would like to figure out a way to prevent the pool size from being set to 10 without having to fork the repo and make this change to do so. Is there any way to do this? I have tried passing in pool_size:0 and pool_size:None into my engine options but it is still getting set to 10 regardless.

    FWIW I am using a custom dialect (https://github.com/chanzuckerberg/sqlalchemy-aurora-data-api), but the driver name starts with "mysql" so it's being caught by this logic regardless.

    opened by olinger 16
  • Add a `py.typed` file?

    Add a `py.typed` file?

    Hi! It looks like the latest release of Flask-SQLAlchemy ships with inline type annotations. This is awesome!

    Would you consider adding a py.typed file to the library? This would mean that we could mark our typeshed stubs for Flask-SQLAlchemy as officially obsolete, and not have to worry about updating our stubs to reflect the changes in 3.0.* (cf. https://github.com/python/typeshed/pull/8849).

    opened by AlexWaygood 15
  • Listening for 'before_flush' throws sqlalchemy.exc.ArgumentError

    Listening for 'before_flush' throws sqlalchemy.exc.ArgumentError

    Registering a listener for 'before_commit' (and 'before_flush') like so, where:

    db = SQLAlchemy(app)
    ...
    event.listen(db.session, 'before_commit', before_commit)
    

    Throws the following exception:

        @event.listens_for(db.session, "before_flush")
      File "/home/environments/python3/lib/python3.3/site-packages/sqlalchemy/event/api.py", line 68, in decorate
        listen(target, identifier, fn, *args, **kw)
      File "/home/environments/python3/lib/python3.3/site-packages/sqlalchemy/event/api.py", line 49, in listen
        _event_key(target, identifier, fn).listen(*args, **kw)
      File "/home/environments/python3/lib/python3.3/site-packages/sqlalchemy/event/api.py", line 22, in _event_key
        tgt = evt_cls._accept_with(target)
      File "/home/environments/python3/lib/python3.3/site-packages/sqlalchemy/orm/events.py", line 1142, in _accept_with
        "Session event listen on a scoped_session "
    sqlalchemy.exc.ArgumentError: Session event listen on a scoped_session requires that its creation callable is associated with the Session class.
    

    Per the comment in this thread from Mike Bayer, it seems the issue is with the factory being passed to scoped_session not being a sessionmaker(): http://stackoverflow.com/questions/21322158/event-listener-on-scoped-session

    Stepping through the code, it barfs in this method in line 1132 of sqlalchemy/orm/events.py:

        @classmethod
        def _accept_with(cls, target):
            if isinstance(target, scoped_session):
    
                target = target.session_factory
                if not isinstance(target, sessionmaker) and \
                    (
                        not isinstance(target, type) or
                        not issubclass(target, Session)
                    ):
                    raise exc.ArgumentError(
                                "Session event listen on a scoped_session "
                                "requires that its creation callable "
                                "is associated with the Session class.")
    

    db.session.session_factory is of type functools.partial, which angers SQLAlchemy.

    opened by acowlikeobject 15
  • Bump dessant/lock-threads from 3 to 4

    Bump dessant/lock-threads from 3 to 4

    Bumps dessant/lock-threads from 3 to 4.

    Release notes

    Sourced from dessant/lock-threads's releases.

    v4.0.0

    Learn more about this release from the changelog.

    Changelog

    Sourced from dessant/lock-threads's changelog.

    4.0.0 (2022-12-04)

    ⚠ BREAKING CHANGES

    • the action now requires Node.js 16

    Bug Fixes

    3.0.0 (2021-09-27)

    ⚠ BREAKING CHANGES

    • input parameter names have changed

      Rename the following input parameters when upgrading from v2 to v3:

      • issue-lock-inactive-days --> issue-inactive-days
      • issue-exclude-created-before --> exclude-issue-created-before
      • issue-exclude-labels --> exclude-any-issue-labels
      • issue-lock-labels --> add-issue-labels
      • issue-lock-comment --> issue-comment
      • pr-lock-inactive-days --> pr-inactive-days
      • pr-exclude-created-before --> exclude-pr-created-before
      • pr-exclude-labels --> exclude-any-pr-labels
      • pr-lock-labels --> add-pr-labels
      • pr-lock-comment --> pr-comment

    Features

    • add new filtering and labeling options, update input parameter names (26fd836)
    • allow manual triggering (a0c7da3)

    2.1.2 (2021-08-17)

    Bug Fixes

    • ignore error when commenting on issue converted to discussion (60d2a1a), closes #24

    2.1.1 (2021-07-09)

    Bug Fixes

    • update GitHub API calls (a3ccc71)

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Documentation bug on queries.rst

    Documentation bug on queries.rst

    On this page https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/queries/#select, the information for querying one object is slightly incorrect.

    user = db.session.execute(db.select(User).filter_by(username=username)).one()
    

    This yields something like:

    (<User 1>,)
    

    I believe this is because we are working with the ORM models, so we need to use ScalarResult instead of Result. See https://docs.sqlalchemy.org/en/14/core/connections.html#sqlalchemy.engine.ScalarResult

    So I think the example should read:

    user = db.session.execute(db.select(User).filter_by(username=username)).scalars().one()
    

    This will yield the model with out the tuple.

    <User 1>
    

    Environment:

    • Python version: 3.11.0
    • Flask-SQLAlchemy version: 3.0.2
    • SQLAlchemy version: 1.4.44

    I'm happy to update the documentation. I was considering sending a pull request, but it's late, so ended up filing a bug instead.

    opened by richard-to 0
  • support `session.get` kwargs

    support `session.get` kwargs

    Support passing kwargs into db.session.get via db.get_or_404.

    • fixes #1149

    Checklist:

    • [x] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
    • [x] Add or update relevant docs, in the docs folder and in code.
    • [x] Add an entry in CHANGES.rst summarizing the change and linking to the issue.
    • [x] Add .. versionchanged:: entries in any relevant code docs.
    • [x] Run pre-commit hooks and fix any issues.
    • [x] Run pytest and tox, no tests failed.
    opened by jdimmerman 0
  • support `session.get` kwargs

    support `session.get` kwargs

    SqlAlchemy supports passing in various kwargs to session.get(), such as options, which allows for joinloading relationships (as an example). Ideally we could do the same to flask-sqlalchemy's extension object's get_or_404(). This would be a simple, backwards compatible change to flask-sqlalchemy's implementation.

    Example:

    from sqlalchemy.dialects.postgresql import UUID
    from uuid import uuid4
    from sqlalchemy.orm import joinedload
    
    class Organization(db.Model):
        __tablename__ = "organization"
        id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid4)
    
    class User(db.Model):
        __tablename__ = "user"
        id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid4)
        organization_id = db.Column(
            UUID(as_uuid=True),
            db.ForeignKey(Organization.id),
        )
        organization = db.relationship("Organization")
       
    
    # currently - emits 2 queries
    my_user = session.get_or_404(User, my_user_id)
    user_organization = my_user.organization
    
    # proposed - emits 1 query
    my_user = session.get_or_404(User, my_user_id, options=[joinedload(User.organization)])
    user_organization = my_user.organization
    

    If this sounds good, I can submit a PR

    opened by jdimmerman 0
  • Support SQLAlchemy 2's `DeclarativeBase` and `MappedAsDataclass`

    Support SQLAlchemy 2's `DeclarativeBase` and `MappedAsDataclass`

    I've been playing with mapped_column and MappedAsDataclass (new stuff in SQLAlchemy 2.x):

    Declarative Table with mapped_column() Declarative Dataclass Mapping

    Example:

    mkdir sqlaplayground
    cd sqlaplayground
    pyenv local 3.11 
    python -m venv .venv 
    source .venv/bin/activate
    pip install -U pip wheel setuptools
    cat requirements.txt
    # sqlalchemy >= 2.0.0b3
    # flask-sqlalchemy @ git+https://github.com/pallets-eco/flask-sqlal[email protected]
    # flask >= 2.0.0
    pip install -r requirements.txt
    
    from __future__ import annotations
    
    from typing import Optional
    
    from sqlalchemy import ForeignKey, String, create_engine, orm
    from sqlalchemy.orm import (
        DeclarativeBase, Mapped, MappedAsDataclass, mapped_column, sessionmaker
    )
    
    CONFIG = {
        "SQLALCHEMY_DATABASE_URI": "sqlite+pysqlite://",
    }
    
    Engine = create_engine(CONFIG["SQLALCHEMY_DATABASE_URI"], future=True)
    Session = sessionmaker(bind=Engine, future=True)
    session = Session()
    
    
    class BaseModel(MappedAsDataclass, DeclarativeBase):
        """subclasses will be converted to dataclasses"""
    
        pass
    
    
    class Book(BaseModel):
        __tablename__ = "books"
    
        id: Mapped[Optional[int]] = mapped_column(
            init=False, primary_key=True, autoincrement=True
        )
    
        title: Mapped[Optional[str]] = mapped_column(String(length=64), default=None)
    
        author_id: Mapped[Optional[int]] = mapped_column(
            ForeignKey("authors.id"), nullable=False, index=True, default=None
        )
        author: Mapped[Optional[Author]] = orm.relationship(
            "Author", uselist=False, back_populates="books", default=None
        )
    
    
    class Author(BaseModel):
        __tablename__ = "authors"
    
        id: Mapped[Optional[int]] = mapped_column(
            init=False, primary_key=True, autoincrement=True
        )
        name: Mapped[Optional[str]] = mapped_column(String(length=64), default=None)
        books: Mapped[list[Book]] = orm.relationship(
            "Book", uselist=True, back_populates="author", default_factory=list
        )
    
    BaseModel.metadata.create_all(Engine)
    
    book = Book(title="42", author=Author(name="Name"))
    session.add(book)
    session.commit()
    

    This rather verbose declaration of models gives us some nice things:

    • more precise mypy and PyRight static typechecking.
    • dataclass-like __init__
    repr(book)
    # "Book(id=1, title='42', author_id=1, author=Author(id=1, name='Name', books=[...]))"
    ?book.__init__
    # book.__init__(title=None, author_id=None, author=None)
    

    First try at using my BaseModel with Flask-SQLAlchemy gets me into trouble with metaclass inheritance:

    import flask
    import flask_sqlalchemy
    
    
    app = flask.Flask(__name__)
    app.config.from_mapping(CONFIG)
    
    db = flask_sqlalchemy.SQLAlchemy(model_class=BaseModel)
    
    # TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) 
    # subclass of the metaclasses of all its bases
    

    which is fair enough...

    I did try few things from Advanced Customization but so far came empty handed.

    Can Flask-SQLAlchemy support this "new" declarative models? Should it? Maybe avoid this problem by somehow replacing metaclass magic with __init_subclass__ from PEP 487 - Simpler customisation of class creation

    opened by tadams42 8
Releases(3.0.2)
  • 3.0.2(Oct 14, 2022)

    This is a fix release for the 3.0.x feature release. It updates compatibility with SQLAlchemy 2.0 beta 1.

    • Changes: https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/changes/#version-3-0-2
    • Milestone: https://github.com/pallets-eco/flask-sqlalchemy/milestone/16?closed=1
    Source code(tar.gz)
    Source code(zip)
  • 3.0.1(Oct 11, 2022)

    This is a fix release for the 3.0.x feature release.

    • Changes: https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/changes/#version-3-0-1
    • Milestone: https://github.com/pallets-eco/flask-sqlalchemy/milestone/14?closed=1
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Oct 4, 2022)

    This is a feature release, which includes new features and removes previously deprecated code. The 3.0.x branch is now the supported bug fix branch, the 2.x branch will become a tag marking the end of support for that branch. We encourage everyone to upgrade, and to use a tool such as pip-tools to pin all dependencies and control upgrades.

    • Changes: https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/changes/#version-3-0-0
    • Milestone: https://github.com/pallets-eco/flask-sqlalchemy/milestone/2?closed=1
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0a2(Sep 26, 2022)

    This is a prerelease to preview the changes in 3.0, the next feature release. Prereleases are an opportunity to test and update your projects early before the final release.

    pip install -U --pre Flask-SQLAlchemy
    

    There were significant changes in https://github.com/pallets-eco/flask-sqlalchemy/pull/1087, see the changelog for a full list. Many of those changes will raise deprecation warnings, but it was not feasible to implement warnings for some things.

    • Changes: https://flask-sqlalchemy.palletsprojects.com/en/latest/changes/#version-3-0-0
    • Milestone: https://github.com/pallets-eco/flask-sqlalchemy/milestone/2?closed=1
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0a1(Sep 18, 2022)

    This is a prerelease to preview the changes in 3.0, the next feature release. Prereleases are an opportunity to test and update your projects early before the final release.

    pip install -U --pre Flask-SQLAlchemy
    

    There were significant changes in https://github.com/pallets-eco/flask-sqlalchemy/pull/1087, see the changelog for a full list. Many of those changes will raise deprecation warnings, but it was not feasible to implement warnings for some things.

    • Changes: https://flask-sqlalchemy.palletsprojects.com/en/latest/changes/#version-3-0-0
    • Milestone: https://github.com/pallets-eco/flask-sqlalchemy/milestone/2?closed=1
    Source code(tar.gz)
    Source code(zip)
  • 2.5.1(Mar 18, 2021)

    Fixed compatibility with SQLAlchemy 1.4 and Python 2.7.

    • Changes: https://flask-sqlalchemy.palletsprojects.com/en/2.x/changelog/#version-2-5-1
    Source code(tar.gz)
    Source code(zip)
  • 2.5.0(Mar 18, 2021)

  • 2.4.4(Jul 14, 2020)

  • 2.4.3(May 26, 2020)

  • 2.4.2(May 25, 2020)

  • 2.3.2(Oct 11, 2017)

  • 2.3.1(Oct 4, 2017)

    Install or upgrade

    Install from PyPI with pip:

    pip install -U Flask-SQLAlchemy
    

    Changelog

    • If a model has a table name that matches an existing table in the metadata, use that table. Fixes a regression where reflected tables were not picked up by models. (#551)
    • Raise the correct error when a model has a table name but no primary key. (#556)
    • Fix repr on models that don't have an identity because they have not been flushed yet. (#555)
    • Allow specifying a max_per_page limit for pagination, to avoid users specifying high values in the request args. (#542)
    • For paginate with error_out=False, the minimum value for page is 1 and per_page is 0. (#558)
    Source code(tar.gz)
    Source code(zip)
    Flask-SQLAlchemy-2.3.1.tar.gz(102.94 KB)
    Flask-SQLAlchemy-2.3.1.tar.gz.asc(488 bytes)
    Flask_SQLAlchemy-2.3.1-py2.py3-none-any.whl(16.22 KB)
    Flask_SQLAlchemy-2.3.1-py2.py3-none-any.whl.asc(488 bytes)
  • 2.3.0(Sep 28, 2017)

    Install or upgrade

    Install from PyPI with pip:

    pip install -U Flask-SQLAlchemy
    

    Changelog

    • Multiple bugs with __tablename__ generation are fixed. Names will be generated for models that define a primary key, but not for single-table inheritance subclasses. Names will not override a declared_attr. PrimaryKeyConstraint is detected. (#541)
    • Passing an existing declarative_base() as model_class to SQLAlchemy.__init__ will use this as the base class instead of creating one. This allows customizing the metaclass used to construct the base. (#546)
    • The undocumented DeclarativeMeta internals that the extension uses for binds and table name generation have been refactored to work as mixins. Documentation is added about how to create a custom metaclass that does not do table name generation. (#546)
    • Model and metaclass code has been moved to a new models module. _BoundDeclarativeMeta is renamed to DefaultMeta; the old name will be removed in 3.0. (#546)
    • Models have a default repr that shows the model name and primary key. (#530)
    • Fixed a bug where using init_app would cause connectors to always use the current_app rather than the app they were created for. This caused issues when multiple apps were registered with the extension. (#547)
    Source code(tar.gz)
    Source code(zip)
    Flask-SQLAlchemy-2.3.0.tar.gz(101.57 KB)
    Flask-SQLAlchemy-2.3.0.tar.gz.asc(488 bytes)
    Flask_SQLAlchemy-2.3.0-py2.py3-none-any.whl(15.84 KB)
    Flask_SQLAlchemy-2.3.0-py2.py3-none-any.whl.asc(488 bytes)
  • 2.2(Feb 27, 2017)

    Install or upgrade

    Install from PyPI with pip:

    pip install -U Flask-SQLAlchemy
    

    Changelog

    • Minimum SQLAlchemy version is 0.8 due to use of sqlalchemy.inspect.
    • Added support for custom query_class and model_class as args to the SQLAlchemy constructor. (#328)
    • Allow listening to SQLAlchemy events on db.session. (#364)
    • Allow __bind_key__ on abstract models. (#373)
    • Allow SQLALCHEMY_ECHO to be a string. (#409)
    • Warn when SQLALCHEMY_DATABASE_URI is not set. (#443)
    • Don't let pagination generate invalid page numbers. (#460)
    • Drop support of Flask < 0.10. This means the db session is always tied to the app context and its teardown event. (#461)
    • Tablename generation logic no longer accesses class properties unless they are declared_attr. (#467)
    Source code(tar.gz)
    Source code(zip)
    Flask-SQLAlchemy-2.2.tar.gz(98.37 KB)
    Flask-SQLAlchemy-2.2.tar.gz.asc(488 bytes)
    Flask_SQLAlchemy-2.2-py2.py3-none-any.whl(14.53 KB)
    Flask_SQLAlchemy-2.2-py2.py3-none-any.whl.asc(488 bytes)
  • 2.1(Nov 16, 2015)

    Released on October 23rd 2015, codename Caesium

    • Table names are automatically generated in more cases, including subclassing mixins and abstract models.
    • Allow using a custom MetaData object.
    • Add support for binds parameter to session.
    Source code(tar.gz)
    Source code(zip)
Adds GraphQL support to your Flask application.

Flask-GraphQL Adds GraphQL support to your Flask application. Usage Just use the GraphQLView view from flask_graphql from flask import Flask from flas

GraphQL Python 1.3k Jan 03, 2023
Harmony, a discord clone, allows users to chat with other users in real time via servers, channels, and direct messages

Harmony, a discord clone, allows users to chat with other users in real time via servers, channels, and direct messages

Seth Holland 3 Feb 03, 2022
A python package for integrating ripozo with Flask

flask-ripozo This package provides a dispatcher for ripozo so that you can integrate ripozo with Flask. As with all dispatchers it is simply for getti

Vertical Knowledge 14 Dec 03, 2018
OpenTracing instrumentation for the Flask microframework

Flask-OpenTracing This package enables distributed tracing in Flask applications via The OpenTracing Project. Once a production system contends with r

3rd-Party OpenTracing API Contributions 133 Dec 19, 2022
An python flask app with webserver example

python-flask-example-keepalive How it works? Basically its just a python flask webserver which can be used to keep any repl/herokuapp or any other ser

KangersHub 2 Sep 28, 2022
A simple Task todo application built with Flask

Task TODO Table An application built with Flask a Python framework and hosted on Heroku. Important notes GuniCorn (Green Unicorn): is a Python WSGI HT

DCN (Dubem Celestine Nwabuisi) 1 Dec 15, 2021
A Flask extension that enables or disables features based on configuration.

Flask FeatureFlags This is a Flask extension that adds feature flagging to your applications. This lets you turn parts of your site on or off based on

Rachel Greenfield 131 Sep 26, 2022
API to get the details of the characters in the Money heist TV show.

Project Heist Description: Project Heist is a RESTful API made using Python and Flask. This API is inspired by the popular Spanish TV show Money Heist

Rahul V 5 Dec 19, 2022
A flask app that turn image into ASCII art

ASCII art A flask app that turn image into ASCII art. This app has been deployed to https://motmaytinh.herokuapp.com Getting Started These instruction

Trần Ngọc Quý 1 Jan 13, 2022
Sample Dockerized flask app deployed on Kubernetes on Azure using AKS

Sample Dockerized flask app deployed on Kubernetes on Azure using AKS

Ahmed khémiri 22 Sep 08, 2021
A Flask wrapper of Starknet state. Similar in purpose to Ganache.

Introduction A Flask wrapper of Starknet state. Similar in purpose to Ganache. Aims to mimic Starknet's Alpha testnet, but with simplified functionali

Shard Labs 159 Jan 04, 2023
Flaskr: Intro to Flask, Test-Driven Development (TDD), and JavaScript

Flaskr - Intro to Flask, Test-Driven Development, and JavaScript Share on Twitter As many of you know, Flaskr -- a mini-blog-like-app -- is the app th

Michael Herman 2.2k Jan 04, 2023
A template themes for phyton flask website

Flask Phyton Web template A template themes for phyton flask website

Mesin Kasir 2 Nov 29, 2021
Map Matching & Weight Completion service - Java (Springboot) & Python(Flask)

Map Matching service to match coordinates to roads using Java and Springboot. Weight Completion service to fill in missing weights in a graph, using Python and Flask.

2 May 13, 2022
Serve angular production application from python flask backend. Quick and Easy

Serve angular production application from python flask backend. Quick and Easy

mark 1 Dec 01, 2022
iloveflask is a Python library to collect functions that help a flask developer generate reports, config files and repeat code.

I Love Flask iloveflask is a Python library to collect functions that help a flask developer generate reports, config files and repeat code. Installat

2 Dec 29, 2021
A fairly common feature in web applications to have links that open a popover when hovered

Add Popovers to Links in Flask App It is a fairly common feature in web applications to have links that open a popover when hovered. Twitter does this

Gitau Harrison 1 Jan 22, 2022
Source code for backpainfree.org - a Q&A platform similar to StackOverFlow

Source code for backpainfree.org - a Q&A platform similar to StackOverFlow, which is designed specifically for people with back pain problems. Users can ask questions, post answers and comments, vote

Olzhas Arystanov 8 Dec 11, 2022
Flask-Starter is a boilerplate starter template designed to help you quickstart your Flask web application development.

Flask-Starter Flask-Starter is a boilerplate starter template designed to help you quickstart your Flask web application development. It has all the r

Kundan Singh 259 Dec 26, 2022
SqlAlchemy Flask-Restful Swagger Json:API OpenAPI

SAFRS: Python OpenAPI & JSON:API Framework Overview Installation JSON:API Interface Resource Objects Relationships Methods Custom Methods Class Method

Thomas Pollet 365 Jan 06, 2023