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

Issues
  • Manage external declarative bases

    Manage external declarative bases

    Fix for Issue #98

    opened by nickw444 70
  • 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 21
  • 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
  • Is the project dead?

    Is the project dead?

    No updates in 9 months, unanswered issues/PRs.

    Just wondering.

    opened by Diaoul 20
  • "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
  • 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
  • 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
  • Migration to SQLAlchemy 2.0

    Migration to SQLAlchemy 2.0

    SQLAlchemy is moving toward a new system, detailed here: https://docs.sqlalchemy.org/en/14/changelog/migration_20.html. Flask-SQLAlchemy should also move in that direction.

    The main difference is that session.query(Model) is being replaced, essentially with, session.execute(select(Model)). The old Session.query() will still be around, but is moved to legacy essentially dropped from maintenance / feature improvement.

    My suggestion is to add a Model.select() method that adheres to this new format. This should be pretty straightforward and possibly already in the works (I didn't see anything though).

    There are likely other ways that FSA could start moving to SQLA 2.0, but the select method is probably a top priority.

    opened by tgross35 7
  • fix: MetaMixin* accept kwargs

    fix: MetaMixin* accept kwargs

    The Metaclass Mixin classes now accept and propagate additional keywords provided.

    The name **kw has been chosen to stay consistent with SQLAlchemy.

    • fixes #1002

    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.
    • [ ] Run pytest and tox, no tests failed.
    opened by indietyp 1
  • Metaclasses do not accept additional keyword arguments

    Metaclasses do not accept additional keyword arguments

    Currently, the metaclass mixins provided by flask-sqlalchemy do not accept additional keyword arguments. Due to that, it breaks compatibility to the __init_subclass_ hook.

    The bug was present in SQLAlchemy, and was fixed in #5357, refer to documentation about the canonical inclusion of kwargs.

    from flask_sqlalchemy import SQLAlchemy
    from sqlalchemy import Column, Integer
    
    db = SQLAlchemy()
    
    
    class Mixin:
        def __init_subclass__(cls, *, default=None, **kwargs):
            super().__init_subclass__(**kwargs)
    
            cls.default = default
    
    
    class Model(db.Model, Mixin, default=2):
        id = Column(Integer, primary_key=True)
    

    The execution of the snippet will result in:

    Traceback (most recent call last):
      File "[omitted]", line 14, in <module>
        class Model(db.Model, Mixin, default=2):
    TypeError: __init__() got an unexpected keyword argument 'default'
    

    The instantiation of the class should not fail, and default should be propagated to the __init_subclass__ hook.

    Environment:

    • Python version: 3.9.7
    • Flask-SQLAlchemy version: 2.5.1
    • SQLAlchemy version: 1.4.23
    opened by indietyp 0
  • fix(2.x): session get bind signature

    fix(2.x): session get bind signature

    Revisiting this issue, patch for 2.x

    The SignallingSession get_bind is being called without any parameters, this is probably due to the new SQLAlchemy proxied mechanism for registering scoped sessions

    (None, None, None, None, False) {}
    

    This is a simple fix that just uses the exact method signature from SQLAlchemy for get_bind of the current session

    fixes: Possible issue on session get_bind #953

    Note: Because of the CI drift between main and 2.x I'm posting my output from tox here:

    =============================================== test session starts ===============================================
    platform darwin -- Python 3.7.6, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
    cachedir: .tox/py37/.pytest_cache
    rootdir: /Users/daniel/workarea/preset/flask-sqlalchemy, configfile: setup.cfg, testpaths: tests
    collected 74 items
    
    tests/test_basic_app.py ....                                                                                [  5%]
    tests/test_binds.py ....                                                                                    [ 10%]
    tests/test_commit_on_teardown.py ..                                                                         [ 13%]
    tests/test_config.py ...................                                                                    [ 39%]
    tests/test_meta_data.py ..                                                                                  [ 41%]
    tests/test_model_class.py ....                                                                              [ 47%]
    tests/test_pagination.py .....                                                                              [ 54%]
    tests/test_query_class.py ...                                                                               [ 58%]
    tests/test_query_property.py ....                                                                           [ 63%]
    tests/test_regressions.py ....                                                                              [ 68%]
    tests/test_sessions.py .....                                                                                [ 75%]
    tests/test_signals.py ..                                                                                    [ 78%]
    tests/test_sqlalchemy_includes.py .                                                                         [ 79%]
    tests/test_table_name.py .............                                                                      [ 97%]
    tests/test_utils.py ..                                                                                      [100%]
    
    ================================================ warnings summary =================================================
    tests/test_commit_on_teardown.py::test_commit_on_success
    tests/test_commit_on_teardown.py::test_roll_back_on_failure
      /Users/daniel/workarea/preset/flask-sqlalchemy/flask_sqlalchemy/__init__.py:903: DeprecationWarning: 'COMMIT_ON_TEARDOWN' is deprecated and will be removed in version 3.1. Call 'db.session.commit()'` directly instead.
        DeprecationWarning,
    
    -- Docs: https://docs.pytest.org/en/stable/warnings.html
    ========================================= 74 passed, 2 warnings in 0.95s ==========================================
    _____________________________________________________ summary _____________________________________________________
      py37: commands succeeded
      congratulations :)
     ~/w/p/flask-sqlalchemy  fix/get-session-bind-2x-v2 *2 ?2  tox -e py38               ok  14s  flask-sqlalchemy py
    GLOB sdist-make: /Users/daniel/workarea/preset/flask-sqlalchemy/setup.py
    py38 create: /Users/daniel/workarea/preset/flask-sqlalchemy/.tox/py38
    py38 installdeps: pytest, coverage, blinker, mock
    py38 inst: /Users/daniel/workarea/preset/flask-sqlalchemy/.tox/.tmp/package/1/Flask-SQLAlchemy-2.5.1.zip
    py38 installed: attrs==21.2.0,blinker==1.4,click==8.0.1,coverage==5.5,Flask==2.0.1,Flask-SQLAlchemy @ file:///Users/daniel/workarea/preset/flask-sqlalchemy/.tox/.tmp/package/1/Flask-SQLAlchemy-2.5.1.zip,greenlet==1.1.1,iniconfig==1.1.1,itsdangerous==2.0.1,Jinja2==3.0.1,MarkupSafe==2.0.1,mock==4.0.3,packaging==21.0,pluggy==1.0.0,py==1.10.0,pyparsing==2.4.7,pytest==6.2.5,SQLAlchemy==1.4.23,toml==0.10.2,Werkzeug==2.0.1
    py38 run-test-pre: PYTHONHASHSEED='1751660045'
    py38 runtests: commands[0] | coverage run -p -m pytest --tb=short --basetemp=/Users/daniel/workarea/preset/flask-sqlalchemy/.tox/py38/tmp
    =============================================== test session starts ===============================================
    platform darwin -- Python 3.8.9, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
    cachedir: .tox/py38/.pytest_cache
    rootdir: /Users/daniel/workarea/preset/flask-sqlalchemy, configfile: setup.cfg, testpaths: tests
    collected 74 items
    
    tests/test_basic_app.py ....                                                                                [  5%]
    tests/test_binds.py ....                                                                                    [ 10%]
    tests/test_commit_on_teardown.py ..                                                                         [ 13%]
    tests/test_config.py ...................                                                                    [ 39%]
    tests/test_meta_data.py ..                                                                                  [ 41%]
    tests/test_model_class.py ....                                                                              [ 47%]
    tests/test_pagination.py .....                                                                              [ 54%]
    tests/test_query_class.py ...                                                                               [ 58%]
    tests/test_query_property.py ....                                                                           [ 63%]
    tests/test_regressions.py ....                                                                              [ 68%]
    tests/test_sessions.py .....                                                                                [ 75%]
    tests/test_signals.py ..                                                                                    [ 78%]
    tests/test_sqlalchemy_includes.py .                                                                         [ 79%]
    tests/test_table_name.py .............                                                                      [ 97%]
    tests/test_utils.py ..                                                                                      [100%]
    
    ================================================ warnings summary =================================================
    tests/test_commit_on_teardown.py::test_commit_on_success
    tests/test_commit_on_teardown.py::test_roll_back_on_failure
      /Users/daniel/workarea/preset/flask-sqlalchemy/flask_sqlalchemy/__init__.py:899: DeprecationWarning: 'COMMIT_ON_TEARDOWN' is deprecated and will be removed in version 3.1. Call 'db.session.commit()'` directly instead.
        warnings.warn(
    
    -- Docs: https://docs.pytest.org/en/stable/warnings.html
    ========================================= 74 passed, 2 warnings in 1.08s ==========================================
    _____________________________________________________ summary _____________________________________________________
      py38: commands succeeded
      congratulations :)
    

    Checklist:

    • [ ] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
    • [ ] Add or update relevant docs, in the docs folder and in code.
    • [ ] Add an entry in CHANGES.rst summarizing the change and linking to the issue.
    • [ ] Add .. versionchanged:: entries in any relevant code docs.
    • [ ] Run pre-commit hooks and fix any issues.
    • [ ] Run pytest and tox, no tests failed.
    opened by dpgaspar 3
  • Sqlite: In-Memory Databases with Shared cache not working

    Sqlite: In-Memory Databases with Shared cache not working

    Hello, I'm loading a sqlite3 database, which is stored on disk to memory via:

    source = sqlite3.connect(os.path.abspath('./db-auth.sqlite'))   
    dest = sqlite3.connect("file:{}?mode=memory&cache=shared".format(sqlite_shared_name), uri=True)   
    source.backup(dest)
    

    Regarding to this SO answer ( https://stackoverflow.com/a/65429612 ) I want to "bind" this in-memory database to flask_SQLAlchemy. But I don't have a create_engine(). I have a Config class which is used via:

    db = SQLAlchemy()  
    app.config.from_object(config_class)  
    db.app = app  
    db.init_app(app)
    

    There he tooks the Database URI from SQLALCHEMY_DATABASE_URI, which is:

    os.environ.get('DATABASE_URL') or "sqlite:///file:{}?mode=memory&cache=shared&uri=true".format(sqlite_shared_name)
    

    But this won't work and I can't query data.

    Environment:

    • Python version: 3.8.10
    • Flask-SQLAlchemy version: 2.5.1
    • SQLAlchemy version: 1.3.12
    opened by YpsilonZet 0
  • SQLite databases are not created in the instance directory

    SQLite databases are not created in the instance directory

    In Flask-SQLAlchemy 2.5.1, when I create a SQLite database connection with a relative path, the database is created in the application root directory rather than the instance directory. It looks like this should have changed in #537, but while that code was merged into main in May 2020 it looks like it has not been included yet in a release.

    Actual Behavior

    config.py:
    SQLALCHEMY_DATABASE_URI = 'sqlite:///development.db'
    

    The file development.db is created in app.root_path. (In this case, ./my-package, which is under source control.)

    Expected Behavior

    The file development.db is created in app.instance_path. (In this case ./instance, which is git-ignored.)

    Environment:

    • Python version: 3.9.5
    • Flask-SQLAlchemy version: 2.5.1
    • SQLAlchemy version: 1.4.23
    opened by chrisbouchard 0
  • Using dataclass with declarative

    Using dataclass with declarative

    The SQL-Alchemy docs show an example to map a dataclass to a table using:

    from dataclasses import dataclass
    from dataclasses import field
    
    from sqlalchemy import Column
    from sqlalchemy import Integer
    from sqlalchemy.orm import registry
    
    mapper_registry = registry()
    
    @mapper_registry.mapped
    @dataclass
    class User:
        __tablename__ = "user"
    
        __sa_dataclass_metadata_key__ = "sa"
        id: int = field(
            init=False, metadata={"sa": Column(Integer, primary_key=True)}
        )
    

    I tried to achieve the same thing using Flask-SQLAlchemy:

    from dataclasses import dataclass
    from dataclasses import field
    
    from sqlalchemy import Column
    from sqlalchemy import Integer
    
    from flask_sqlalchemy import SQLAlchemy
    
    db = SQLAlchemy()
    
    @dataclass
    class User(db.Model):
        __sa_dataclass_metadata_key__ = "sa"
        id: int = field(
            init=False, metadata={"sa": Column(Integer, primary_key=True)}
        )
    

    which yields the following error: sqlalchemy.exc.ArgumentError: Mapper mapped class User->user could not assemble any primary key columns for mapped table 'user'

    I also tried to use the mapper_registry with

    @db.Model.registry.mapped
    @dataclass
    class User:
        __tablename__ = 'user'
        __sa_dataclass_metadata_key__ = "sa"
        id: int = field(
            init=False, metadata={"sa": Column(Integer, primary_key=True)}
        )
    

    but I then lose all the benefits from Flask-SQLAlchemy.

    Would it be possible to add support for dataclasses in Flask-SQLAlchemy?

    opened by jonathanberthias 1
  • Change the __bind_key__ dynamically on model before querying?

    Change the __bind_key__ dynamically on model before querying?

    I need to retrieve data from several databases, same data model, different data.

    class SomeModel(db.Model):
        id = db.Column(db.Integer, primary_key=True, nullable=False)
        site = db.Column(db.String)
        other = db.Column(db.String)
    
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/main.db'
    app.config['SQLALCHEMY_BINDS'] = {
        'site1':'sqlite:////tmp/site1.db'',
        'site2':'sqlite:////tmp/site2.db'',
     }
    
    def get_data(site):
       model = SomeModel()
       model.__bind_key__ = site
       return model.query.all()
    

    It does not work but is there a way to achieve this?

    opened by mxdev88 2
  • 2.5.1: pytest warnings

    2.5.1: pytest warnings

    + /usr/bin/python3 -Bm pytest -ra
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
    rootdir: /home/tkloczko/rpmbuild/BUILD/Flask-SQLAlchemy-2.5.1, configfile: setup.cfg, testpaths: tests
    plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, cov-2.11.1, httpbin-1.0.0, xdist-2.2.1, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, pyfakefs-4.4.0, freezegun-0.4.2, cases-3.4.6, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, flaky-3.7.0, aiohttp-0.3.0, checkdocs-2.7.0, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, hypothesis-6.13.7, Faker-8.4.0
    collected 73 items
    
    tests/test_basic_app.py ....                                                                                                                                         [  5%]
    tests/test_binds.py ....                                                                                                                                             [ 10%]
    tests/test_commit_on_teardown.py ..                                                                                                                                  [ 13%]
    tests/test_config.py ...................                                                                                                                             [ 39%]
    tests/test_meta_data.py ..                                                                                                                                           [ 42%]
    tests/test_model_class.py ....                                                                                                                                       [ 47%]
    tests/test_pagination.py .....                                                                                                                                       [ 54%]
    tests/test_query_class.py ...                                                                                                                                        [ 58%]
    tests/test_query_property.py ....                                                                                                                                    [ 64%]
    tests/test_regressions.py ....                                                                                                                                       [ 69%]
    tests/test_sessions.py ....                                                                                                                                          [ 75%]
    tests/test_signals.py ..                                                                                                                                             [ 78%]
    tests/test_sqlalchemy_includes.py .                                                                                                                                  [ 79%]
    tests/test_table_name.py .............                                                                                                                               [ 97%]
    tests/test_utils.py ..                                                                                                                                               [100%]
    
    ============================================================================= warnings summary =============================================================================
    tests/test_commit_on_teardown.py::test_commit_on_success
    tests/test_commit_on_teardown.py::test_roll_back_on_failure
      /home/tkloczko/rpmbuild/BUILD/Flask-SQLAlchemy-2.5.1/flask_sqlalchemy/__init__.py:889: DeprecationWarning: 'COMMIT_ON_TEARDOWN' is deprecated and will be removed in version 3.1. Call 'db.session.commit()'` directly instead.
        warnings.warn(
    
    -- Docs: https://docs.pytest.org/en/stable/warnings.html
    ====================================================================== 73 passed, 2 warnings in 1.37s ======================================================================
    
    opened by kloczek 0
  • Misleading __repr__

    Misleading __repr__

    The standard repr is misleading such that:

    instance_state = inspect(item)
    print(f"{item = }; {instance_state.transient = }; {instance_state.pending = }")  
    # item = <Competition (transient 140147915565184)>; instance_state.transient = False; instance_state.pending = True
    

    I spent a small amount of time debugging why my instance was transient after I thought it should already be in the session and therefore pending. SQLAlchemy defines transient as:

    an instance that’s not in a session, and is not saved to the database; i.e. it has no database identity. The only relationship such an object has to the ORM is that its class has a Mapper associated with it.

    On the surface, the repr looks as though it is presenting the instance states as they are defined by SQLAlchemy. Given that the word "transient" has a very specific meaning, overloading it here with a different meaning doesn't quite feel right to me.

    Can we afford to be more specific about object state in the repr or use an alternate word to "transient"? Or has the ship sailed?

    https://github.com/pallets/flask-sqlalchemy/blob/9a467c19a6b58bdbbff55eb16dcfb6337a51ace6/src/flask_sqlalchemy/model.py#L132-L140

    opened by peterschutt 0
Releases(2.5.1)
The ormar package is an async mini ORM for Python, with support for Postgres, MySQL, and SQLite.

python async mini orm with fastapi in mind and pydantic validation

null 674 Oct 23, 2021
SQLModel is a library for interacting with SQL databases from Python code, with Python objects.

SQLModel is a library for interacting with SQL databases from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.

Sebastián Ramírez 5.5k Oct 24, 2021
MongoEngine flask extension with WTF model forms support

Flask-MongoEngine Info: MongoEngine for Flask web applications. Repository: https://github.com/MongoEngine/flask-mongoengine About Flask-MongoEngine i

MongoEngine 788 Oct 14, 2021
An async ORM. 🗃

ORM The orm package is an async ORM for Python, with support for Postgres, MySQL, and SQLite. ORM is built with: SQLAlchemy core for query building. d

Encode 1.4k Oct 11, 2021
a small, expressive orm -- supports postgresql, mysql and sqlite

peewee Peewee is a simple and small ORM. It has few (but expressive) concepts, making it easy to learn and intuitive to use. a small, expressive ORM p

Charles Leifer 8.7k Oct 25, 2021
A very simple CRUD class for SQLModel! ✨

Base SQLModel A very simple CRUD class for SQLModel! ✨ Inspired on: Full Stack FastAPI and PostgreSQL - Base Project Generator FastAPI Microservices I

Marcelo Trylesinski 12 Oct 22, 2021
Pony Object Relational Mapper

Downloads Pony Object-Relational Mapper Pony is an advanced object-relational mapper. The most interesting feature of Pony is its ability to write que

null 2.7k Oct 25, 2021
A pythonic interface to Amazon's DynamoDB

PynamoDB A Pythonic interface for Amazon's DynamoDB. DynamoDB is a great NoSQL service provided by Amazon, but the API is verbose. PynamoDB presents y

null 1.7k Oct 23, 2021
Pydantic model support for Django ORM

Pydantic model support for Django ORM

Jordan Eremieff 189 Oct 23, 2021
Piccolo - A fast, user friendly ORM and query builder which supports asyncio.

A fast, user friendly ORM and query builder which supports asyncio.

null 566 Oct 20, 2021
Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions.

dataset: databases for lazy people In short, dataset makes reading and writing data in databases as simple as reading and writing JSON files. Read the

Friedrich Lindenberg 4.1k Oct 18, 2021
Rich Python data types for Redis

Created by Stephen McDonald Introduction HOT Redis is a wrapper library for the redis-py client. Rather than calling the Redis commands directly from

Stephen McDonald 273 Sep 2, 2021
A Python Object-Document-Mapper for working with MongoDB

MongoEngine Info: MongoEngine is an ORM-like layer on top of PyMongo. Repository: https://github.com/MongoEngine/mongoengine Author: Harry Marr (http:

MongoEngine 3.6k Oct 24, 2021
A Python Library for Simple Models and Containers Persisted in Redis

Redisco Python Containers and Simple Models for Redis Description Redisco allows you to store objects in Redis. It is inspired by the Ruby library Ohm

sebastien requiem 434 Oct 1, 2021
Tortoise ORM is an easy-to-use asyncio ORM inspired by Django.

Tortoise ORM was build with relations in mind and admiration for the excellent and popular Django ORM. It's engraved in it's design that you are working not with just tables, you work with relational data.

Tortoise 2.4k Oct 20, 2021