PROJECT HAS BEEN RENAMED TO FastSQLA
Check FastSQLA on Github or PyPI
FastAPI-Async-SQLA
FastAPI-Async-SQLA is an SQLAlchemy extension for FastAPI. It supports asynchronous SQLAlchemy sessions using SQLAlchemy >= 2.0 and provides pagination support.
Installing
Using pip:
pip install fastapi-async-sqla
Quick Example
Assuming it runs against a DB with a table user with 2 columns id and name:
# main.py
from fastapi import FastAPI, HTTPException
from fastapi_async_sqla import Base, Item, Page, Paginate, Session, lifespan
from pydantic import BaseModel
from sqlalchemy import select
app = FastAPI(lifespan=lifespan)
class User(Base):
__tablename__ = "user"
class UserIn(BaseModel):
name: str
class UserModel(UserIn):
id: int
@app.get("/users", response_model=Page[UserModel])
async def list_users(paginate: Paginate):
return await paginate(select(User))
@app.get("/users/{user_id}", response_model=Item[UserModel])
async def get_user(user_id: int, session: Session):
user = await session.get(User, user_id)
if user is None:
raise HTTPException(404)
return {"data": user}
@app.post("/users", response_model=Item[UserModel])
async def create_user(new_user: UserIn, session: Session):
user = User(**new_user.model_dump())
session.add(user)
await session.flush()
return {"data": user}
Creating a db using sqlite3:
sqlite3 db.sqlite <<EOF
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
);
EOF
Installing aiosqlite to connect to the sqlite db asynchronously:
pip install aiosqlite
Running the app:
sqlalchemy_url=sqlite+aiosqlite:///db.sqlite?check_same_thread=false uvicorn main:app
Metadata
Release files for FastAPI-Async-SQLA 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_async_sqla-0.2.4.tar.gz | 5.4 kB | Without provenance | Details for fastapi_async_sqla-0.2.4.tar.gz |
Release files / fastapi_async_sqla-0.2.4.tar.gz
| Download URL | fastapi_async_sqla-0.2.4.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f33439e69cefc74f165fc237442b49ace914db243e5fd5d18e80c551ed732c3
|
|
BLAKE2b-256 checksum How to use checksums |
2053f0fc6b39d6dc369e41212829329830d360d38b5a2ea4bc361cdc875bdea9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.1
|
Security for FastAPI-Async-SQLA 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.