Flask-SQLAlchemy


NameFlask-SQLAlchemy JSON
Version 3.1.1 PyPI version JSON
download
home_page
SummaryAdd SQLAlchemy support to your Flask application.
upload_time2023-09-11 21:42:36
maintainer
docs_urlhttps://pythonhosted.org/Flask-SQLAlchemy/
author
requires_python>=3.8
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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.

.. _Flask: https://palletsprojects.com/p/flask/
.. _SQLAlchemy: https://www.sqlalchemy.org


Installing
----------

Install and update using `pip`_:

.. code-block:: text

  $ pip install -U Flask-SQLAlchemy

.. _pip: https://pip.pypa.io/en/stable/getting-started/


A Simple Example
----------------

.. code-block:: python

    from flask import Flask
    from flask_sqlalchemy import SQLAlchemy
    from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column

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

    class Base(DeclarativeBase):
      pass

    db = SQLAlchemy(app, model_class=Base)

    class User(db.Model):
        id: Mapped[int] = mapped_column(db.Integer, primary_key=True)
        username: Mapped[str] = mapped_column(db.String, unique=True, nullable=False)

    with app.app_context():
        db.create_all()

        db.session.add(User(username="example"))
        db.session.commit()

        users = db.session.execute(db.select(User)).scalars()


Contributing
------------

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

.. _contributing guidelines: https://github.com/pallets-eco/flask-sqlalchemy/blob/main/CONTRIBUTING.rst


Donate
------

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

.. _please donate today: https://palletsprojects.com/donate


Links
-----

-   Documentation: https://flask-sqlalchemy.palletsprojects.com/
-   Changes: https://flask-sqlalchemy.palletsprojects.com/changes/
-   PyPI Releases: https://pypi.org/project/Flask-SQLAlchemy/
-   Source Code: https://github.com/pallets-eco/flask-sqlalchemy/
-   Issue Tracker: https://github.com/pallets-eco/flask-sqlalchemy/issues/
-   Website: https://palletsprojects.com/
-   Twitter: https://twitter.com/PalletsTeam
-   Chat: https://discord.gg/pallets


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "Flask-SQLAlchemy",
    "maintainer": "",
    "docs_url": "https://pythonhosted.org/Flask-SQLAlchemy/",
    "requires_python": ">=3.8",
    "maintainer_email": "Pallets <contact@palletsprojects.com>",
    "keywords": "",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/91/53/b0a9fcc1b1297f51e68b69ed3b7c3c40d8c45be1391d77ae198712914392/flask_sqlalchemy-3.1.1.tar.gz",
    "platform": null,
    "description": "Flask-SQLAlchemy\n================\n\nFlask-SQLAlchemy is an extension for `Flask`_ that adds support for\n`SQLAlchemy`_ to your application. It aims to simplify using SQLAlchemy\nwith Flask by providing useful defaults and extra helpers that make it\neasier to accomplish common tasks.\n\n.. _Flask: https://palletsprojects.com/p/flask/\n.. _SQLAlchemy: https://www.sqlalchemy.org\n\n\nInstalling\n----------\n\nInstall and update using `pip`_:\n\n.. code-block:: text\n\n  $ pip install -U Flask-SQLAlchemy\n\n.. _pip: https://pip.pypa.io/en/stable/getting-started/\n\n\nA Simple Example\n----------------\n\n.. code-block:: python\n\n    from flask import Flask\n    from flask_sqlalchemy import SQLAlchemy\n    from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column\n\n    app = Flask(__name__)\n    app.config[\"SQLALCHEMY_DATABASE_URI\"] = \"sqlite:///example.sqlite\"\n\n    class Base(DeclarativeBase):\n      pass\n\n    db = SQLAlchemy(app, model_class=Base)\n\n    class User(db.Model):\n        id: Mapped[int] = mapped_column(db.Integer, primary_key=True)\n        username: Mapped[str] = mapped_column(db.String, unique=True, nullable=False)\n\n    with app.app_context():\n        db.create_all()\n\n        db.session.add(User(username=\"example\"))\n        db.session.commit()\n\n        users = db.session.execute(db.select(User)).scalars()\n\n\nContributing\n------------\n\nFor guidance on setting up a development environment and how to make a\ncontribution to Flask-SQLAlchemy, see the `contributing guidelines`_.\n\n.. _contributing guidelines: https://github.com/pallets-eco/flask-sqlalchemy/blob/main/CONTRIBUTING.rst\n\n\nDonate\n------\n\nThe Pallets organization develops and supports Flask-SQLAlchemy and\nother popular packages. In order to grow the community of contributors\nand users, and allow the maintainers to devote more time to the\nprojects, `please donate today`_.\n\n.. _please donate today: https://palletsprojects.com/donate\n\n\nLinks\n-----\n\n-   Documentation: https://flask-sqlalchemy.palletsprojects.com/\n-   Changes: https://flask-sqlalchemy.palletsprojects.com/changes/\n-   PyPI Releases: https://pypi.org/project/Flask-SQLAlchemy/\n-   Source Code: https://github.com/pallets-eco/flask-sqlalchemy/\n-   Issue Tracker: https://github.com/pallets-eco/flask-sqlalchemy/issues/\n-   Website: https://palletsprojects.com/\n-   Twitter: https://twitter.com/PalletsTeam\n-   Chat: https://discord.gg/pallets\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Add SQLAlchemy support to your Flask application.",
    "version": "3.1.1",
    "project_urls": {
        "Changes": "https://flask-sqlalchemy.palletsprojects.com/changes/",
        "Chat": "https://discord.gg/pallets",
        "Documentation": "https://flask-sqlalchemy.palletsprojects.com",
        "Donate": "https://palletsprojects.com/donate",
        "Issue Tracker": "https://github.com/pallets-eco/flask-sqlalchemy/issues/",
        "Source Code": "https://github.com/pallets-eco/flask-sqlalchemy/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1d6a89963a5c6ecf166e8be29e0d1bf6806051ee8fe6c82e232842e3aeac9204",
                "md5": "e0575e969b5fd5861e4caedcfe43f61a",
                "sha256": "4ba4be7f419dc72f4efd8802d69974803c37259dd42f3913b0dcf75c9447e0a0"
            },
            "downloads": -1,
            "filename": "flask_sqlalchemy-3.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e0575e969b5fd5861e4caedcfe43f61a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 25125,
            "upload_time": "2023-09-11T21:42:34",
            "upload_time_iso_8601": "2023-09-11T21:42:34.514878Z",
            "url": "https://files.pythonhosted.org/packages/1d/6a/89963a5c6ecf166e8be29e0d1bf6806051ee8fe6c82e232842e3aeac9204/flask_sqlalchemy-3.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9153b0a9fcc1b1297f51e68b69ed3b7c3c40d8c45be1391d77ae198712914392",
                "md5": "b2439ba29a86fd594e0de4fc0e42ceb6",
                "sha256": "e4b68bb881802dda1a7d878b2fc84c06d1ee57fb40b874d3dc97dabfa36b8312"
            },
            "downloads": -1,
            "filename": "flask_sqlalchemy-3.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b2439ba29a86fd594e0de4fc0e42ceb6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 81899,
            "upload_time": "2023-09-11T21:42:36",
            "upload_time_iso_8601": "2023-09-11T21:42:36.147333Z",
            "url": "https://files.pythonhosted.org/packages/91/53/b0a9fcc1b1297f51e68b69ed3b7c3c40d8c45be1391d77ae198712914392/flask_sqlalchemy-3.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-11 21:42:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pallets-eco",
    "github_project": "flask-sqlalchemy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "flask-sqlalchemy"
}
        
Elapsed time: 1.15263s