METADATA 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. Metadata-Version: 2.1
  2. Name: Flask-SQLAlchemy
  3. Version: 3.1.1
  4. Summary: Add SQLAlchemy support to your Flask application.
  5. Maintainer-email: Pallets <contact@palletsprojects.com>
  6. Requires-Python: >=3.8
  7. Description-Content-Type: text/x-rst
  8. Classifier: Development Status :: 5 - Production/Stable
  9. Classifier: Environment :: Web Environment
  10. Classifier: Intended Audience :: Developers
  11. Classifier: License :: OSI Approved :: BSD License
  12. Classifier: Operating System :: OS Independent
  13. Classifier: Programming Language :: Python
  14. Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
  15. Requires-Dist: flask>=2.2.5
  16. Requires-Dist: sqlalchemy>=2.0.16
  17. Project-URL: Changes, https://flask-sqlalchemy.palletsprojects.com/changes/
  18. Project-URL: Chat, https://discord.gg/pallets
  19. Project-URL: Documentation, https://flask-sqlalchemy.palletsprojects.com
  20. Project-URL: Donate, https://palletsprojects.com/donate
  21. Project-URL: Issue Tracker, https://github.com/pallets-eco/flask-sqlalchemy/issues/
  22. Project-URL: Source Code, https://github.com/pallets-eco/flask-sqlalchemy/
  23. Flask-SQLAlchemy
  24. ================
  25. Flask-SQLAlchemy is an extension for `Flask`_ that adds support for
  26. `SQLAlchemy`_ to your application. It aims to simplify using SQLAlchemy
  27. with Flask by providing useful defaults and extra helpers that make it
  28. easier to accomplish common tasks.
  29. .. _Flask: https://palletsprojects.com/p/flask/
  30. .. _SQLAlchemy: https://www.sqlalchemy.org
  31. Installing
  32. ----------
  33. Install and update using `pip`_:
  34. .. code-block:: text
  35. $ pip install -U Flask-SQLAlchemy
  36. .. _pip: https://pip.pypa.io/en/stable/getting-started/
  37. A Simple Example
  38. ----------------
  39. .. code-block:: python
  40. from flask import Flask
  41. from flask_sqlalchemy import SQLAlchemy
  42. from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
  43. app = Flask(__name__)
  44. app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///example.sqlite"
  45. class Base(DeclarativeBase):
  46. pass
  47. db = SQLAlchemy(app, model_class=Base)
  48. class User(db.Model):
  49. id: Mapped[int] = mapped_column(db.Integer, primary_key=True)
  50. username: Mapped[str] = mapped_column(db.String, unique=True, nullable=False)
  51. with app.app_context():
  52. db.create_all()
  53. db.session.add(User(username="example"))
  54. db.session.commit()
  55. users = db.session.execute(db.select(User)).scalars()
  56. Contributing
  57. ------------
  58. For guidance on setting up a development environment and how to make a
  59. contribution to Flask-SQLAlchemy, see the `contributing guidelines`_.
  60. .. _contributing guidelines: https://github.com/pallets-eco/flask-sqlalchemy/blob/main/CONTRIBUTING.rst
  61. Donate
  62. ------
  63. The Pallets organization develops and supports Flask-SQLAlchemy and
  64. other popular packages. In order to grow the community of contributors
  65. and users, and allow the maintainers to devote more time to the
  66. projects, `please donate today`_.
  67. .. _please donate today: https://palletsprojects.com/donate
  68. Links
  69. -----
  70. - Documentation: https://flask-sqlalchemy.palletsprojects.com/
  71. - Changes: https://flask-sqlalchemy.palletsprojects.com/changes/
  72. - PyPI Releases: https://pypi.org/project/Flask-SQLAlchemy/
  73. - Source Code: https://github.com/pallets-eco/flask-sqlalchemy/
  74. - Issue Tracker: https://github.com/pallets-eco/flask-sqlalchemy/issues/
  75. - Website: https://palletsprojects.com/
  76. - Twitter: https://twitter.com/PalletsTeam
  77. - Chat: https://discord.gg/pallets