Integrate SQLAlchemy with Flask.
Project description
Flask-SQLAlchemy-Lite
Integrate SQLAlchemy with Flask. Use Flask's config to define SQLAlchemy database engines. Create SQLAlchemy ORM sessions that are cleaned up automatically after requests.
Intended to be a replacement for Flask-SQLAlchemy. Unlike the prior extension, this one does not attempt to manage the model base class, tables, metadata, or multiple binds for sessions. This makes the extension much simpler, letting the developer use standard SQLAlchemy instead.
Pallets Community Ecosystem
[!IMPORTANT]
This project is part of the Pallets Community Ecosystem. Pallets is the open source organization that maintains Flask; Pallets-Eco enables community maintenance of Flask extensions. If you are interested in helping maintain this project, please reach out on the Pallets Discord server.
A Simple Example
from flask import Flask
from flask_sqlalchemy_lite import SQLAlchemy
from sqlalchemy import select
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
class Base(DeclarativeBase):
pass
class User(Base):
__tablename__ = "user"
id: Mapped[int] = mapped_column(primary_key=True)
username: Mapped[str] = mapped_column(unique=True)
app = Flask(__name__)
app.config["SQLALCHEMY_ENGINES"] = {"default": "sqlite:///default.sqlite"}
db = SQLAlchemy(app)
with app.app_context():
Base.metadata.create_all(db.engine)
db.session.add(User(username="example"))
db.session.commit()
users = db.session.scalars(select(User))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flask_sqlalchemy_lite-0.2.1.tar.gz.
File metadata
- Download URL: flask_sqlalchemy_lite-0.2.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6de2f70c835a2c0a11264cbbc0cc33e7ed9732a52ee056781c5739e960213d2f
|
|
| MD5 |
f587b8b1330a8022ce277ff6288d17fe
|
|
| BLAKE2b-256 |
b7dc3f4c55cfc03e189e50b80843d5d3ff70c97711d924537b7a5ad8587cf7fb
|
Provenance
The following attestation bundles were made for flask_sqlalchemy_lite-0.2.1.tar.gz:
Publisher:
publish.yaml on pallets-eco/flask-sqlalchemy-lite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_sqlalchemy_lite-0.2.1.tar.gz -
Subject digest:
6de2f70c835a2c0a11264cbbc0cc33e7ed9732a52ee056781c5739e960213d2f - Sigstore transparency entry: 711508744
- Sigstore integration time:
-
Permalink:
pallets-eco/flask-sqlalchemy-lite@f4a04ce826b71f3741cab6f7526043fb02ea3a1f -
Branch / Tag:
refs/tags/0.2.1 - Owner: https://github.com/pallets-eco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@f4a04ce826b71f3741cab6f7526043fb02ea3a1f -
Trigger Event:
push
-
Statement type:
File details
Details for the file flask_sqlalchemy_lite-0.2.1-py3-none-any.whl.
File metadata
- Download URL: flask_sqlalchemy_lite-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93f1df6228389fdc60a0733353f8c1a18aaeaf03c8d6ab541bafdf2987c5e777
|
|
| MD5 |
9de693ff456d658d2f3944db5678d5aa
|
|
| BLAKE2b-256 |
20f3df9d508d4ed9657ae23d9e936ca2f2c0556742c032598e0d79f78e64646f
|
Provenance
The following attestation bundles were made for flask_sqlalchemy_lite-0.2.1-py3-none-any.whl:
Publisher:
publish.yaml on pallets-eco/flask-sqlalchemy-lite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_sqlalchemy_lite-0.2.1-py3-none-any.whl -
Subject digest:
93f1df6228389fdc60a0733353f8c1a18aaeaf03c8d6ab541bafdf2987c5e777 - Sigstore transparency entry: 711508758
- Sigstore integration time:
-
Permalink:
pallets-eco/flask-sqlalchemy-lite@f4a04ce826b71f3741cab6f7526043fb02ea3a1f -
Branch / Tag:
refs/tags/0.2.1 - Owner: https://github.com/pallets-eco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@f4a04ce826b71f3741cab6f7526043fb02ea3a1f -
Trigger Event:
push
-
Statement type: