Skip to content

Commit dc74599

Browse files
committed
docs: change project name & write a better README
1 parent db4c605 commit dc74599

File tree

12 files changed

+119
-71
lines changed

12 files changed

+119
-71
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: 🔧 setup uv
1414
uses: ./.github/uv
1515
- name: 🧪 pytest
16-
run: uv run pytest --cov fastapi_async_sqla --cov-report=term-missing --cov-report=xml
16+
run: uv run pytest --cov fastsqla --cov-report=term-missing --cov-report=xml
1717
- name: "🐔 codecov: upload test coverage"
1818
uses: codecov/[email protected]
1919
env:

README.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
1-
# FastAPI-Async-SQLA
1+
# FastSQLA
22

3-
[![PyPI - Version](https://img.shields.io/pypi/v/FastAPI-Async-SQLA?color=brightgreen)](https://pypi.org/project/FastAPI-Async-SQLA/)
3+
[![PyPI - Version](https://img.shields.io/pypi/v/FastSQLA?color=brightgreen)](https://pypi.org/project/FastSQLA/)
44
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-brightgreen.svg)](https://conventionalcommits.org)
5-
[![codecov](https://codecov.io/gh/hadrien/fastapi-async-sqla/graph/badge.svg?token=XK3YT60MWK)](https://codecov.io/gh/hadrien/fastapi-async-sqla)
5+
[![codecov](https://codecov.io/gh/hadrien/fastsqla/graph/badge.svg?token=XK3YT60MWK)](https://codecov.io/gh/hadrien/fastsqla)
66

7-
FastAPI-Async-SQLA is an [SQLAlchemy] extension for [FastAPI]. It supports asynchronous
8-
SQLAlchemy sessions using SQLAlchemy >= 2.0 and provides pagination support.
7+
FastSQLA is an [SQLAlchemy] extension for [FastAPI]. It supports asynchronous
8+
SQLAlchemy sessions using SQLAlchemy >= 2.0 and include built-in pagination.
99

1010
# Installing
1111

12+
Using [uv](https://docs.astral.sh/uv/):
13+
```bash
14+
uv add fastsqla
15+
```
16+
1217
Using [pip](https://pip.pypa.io/):
1318
```
14-
pip install fastapi-async-sqla
19+
pip install fastsqla
1520
```
1621

1722
# Quick Example
1823

24+
>! Note
25+
>! Example uses an sqlite db, but FastSQLA is compatible with any async db supported by
26+
>! SQLAlchemy
27+
1928
Assuming it runs against a DB with a table `user` with 2 columns `id` and `name`:
2029

2130
```python
2231
# main.py
2332
from fastapi import FastAPI, HTTPException
24-
from fastapi_async_sqla import Base, Item, Page, Paginate, Session, lifespan
33+
from fastsqla import Base, Item, Page, Paginate, Session, lifespan
2534
from pydantic import BaseModel
2635
from sqlalchemy import select
2736

@@ -62,16 +71,35 @@ async def create_user(new_user: UserIn, session: Session):
6271
return {"data": user}
6372
```
6473

65-
Creating a db using `sqlite3`:
74+
75+
Create an `sqlite3` db:
76+
6677
```bash
6778
sqlite3 db.sqlite <<EOF
68-
CREATE TABLE user (
69-
id INTEGER PRIMARY KEY AUTOINCREMENT,
70-
name TEXT NOT NULL
79+
sqlite3 db.sqlite <<EOF
80+
CREATE TABLE hero (
81+
id INTEGER PRIMARY KEY AUTOINCREMENT,
82+
name TEXT NOT NULL UNIQUE, -- Hero name (e.g., Superman)
83+
secret_identity TEXT NOT NULL -- Secret identity (e.g., Clark Kent)
7184
);
85+
86+
-- Insert heroes with hero name and secret identity
87+
INSERT INTO hero (name, secret_identity) VALUES ('Superman', 'Clark Kent');
88+
INSERT INTO hero (name, secret_identity) VALUES ('Batman', 'Bruce Wayne');
89+
INSERT INTO hero (name, secret_identity) VALUES ('Wonder Woman', 'Diana Prince');
90+
INSERT INTO hero (name, secret_identity) VALUES ('Iron Man', 'Tony Stark');
91+
INSERT INTO hero (name, secret_identity) VALUES ('Spider-Man', 'Peter Parker');
92+
INSERT INTO hero (name, secret_identity) VALUES ('Captain America', 'Steve Rogers');
93+
INSERT INTO hero (name, secret_identity) VALUES ('Black Widow', 'Natasha Romanoff');
94+
INSERT INTO hero (name, secret_identity) VALUES ('Thor', 'Thor Odinson');
95+
INSERT INTO hero (name, secret_identity) VALUES ('Scarlet Witch', 'Wanda Maximoff');
96+
INSERT INTO hero (name, secret_identity) VALUES ('Doctor Strange', 'Stephen Strange');
97+
INSERT INTO hero (name, secret_identity) VALUES ('The Flash', 'Barry Allen');
98+
INSERT INTO hero (name, secret_identity) VALUES ('Green Lantern', 'Hal Jordan');
7299
EOF
73100
```
74101

102+
75103
Installing [aiosqlite] to connect to the sqlite db asynchronously:
76104
```bash
77105
pip install aiosqlite

pyproject.toml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
2-
name = "FastAPI-Async-SQLA"
2+
name = "FastSQLA"
33
version = "0.2.3"
4-
description = "SQLAlchemy extension for FastAPI with support for asynchronous SQLAlchemy sessions and pagination."
4+
description = "SQLAlchemy extension for FastAPI that supports asynchronous sessions and includes built-in pagination."
55
readme = "README.md"
66
requires-python = ">=3.12"
77
authors = [{ name = "Hadrien David", email = "[email protected]" }]
@@ -33,18 +33,14 @@ classifiers = [
3333
]
3434
keywords = ["FastAPI", "SQLAlchemy", "AsyncIO"]
3535
license = { text = "MIT License" }
36-
dependencies = [
37-
"fastapi>=0.115.6",
38-
"sqlalchemy[asyncio]>=2.0.34,<3",
39-
"structlog>=24.4.0",
40-
]
36+
dependencies = ["fastapi>=0.115.6", "sqlalchemy[asyncio]>=2.0.37", "structlog>=24.4.0"]
4137

4238
[project.urls]
43-
Homepage = "https://github.com/hadrien/fastapi-async-sqla"
44-
Documentation = "https://github.com/hadrien/fastapi-async-sqla"
45-
Repository = "https://github.com/hadrien/fastapi-async-sqla"
46-
Issues = "https://github.com/hadrien/fastapi-async-sqla/issues"
47-
Changelog = "https://github.com/hadrien/fastapi-async-sqla/releases"
39+
Homepage = "https://github.com/hadrien/fastsqla"
40+
Documentation = "https://github.com/hadrien/fastsqla"
41+
Repository = "https://github.com/hadrien/fastsqla"
42+
Issues = "https://github.com/hadrien/fastsqla/issues"
43+
Changelog = "https://github.com/hadrien/fastsqla/releases"
4844

4945
[tool.uv]
5046
package = true

src/fastapi_async_sqla.py renamed to src/fastsqla.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Base(DeclarativeBase, DeferredReflection):
4040

4141

4242
class State(TypedDict):
43-
fastapi_async_sqla_engine: AsyncEngine
43+
fastsqla_engine: AsyncEngine
4444

4545

4646
@asynccontextmanager
@@ -60,7 +60,7 @@ async def lifespan(_) -> AsyncGenerator[State, None]:
6060

6161
await logger.ainfo("Configured SQLAlchemy.")
6262

63-
yield {"fastapi_async_sqla_engine": engine}
63+
yield {"fastsqla_engine": engine}
6464

6565
SessionFactory.configure(bind=None)
6666
await engine.dispose()
@@ -120,7 +120,7 @@ class Collection(BaseModel, Generic[T]):
120120
data: list[T]
121121

122122

123-
class Page(Collection):
123+
class Page(Collection[T]):
124124
meta: Meta
125125

126126

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def session(engine):
3232
def tear_down():
3333
from sqlalchemy.orm import clear_mappers
3434

35-
from fastapi_async_sqla import Base
35+
from fastsqla import Base
3636

3737
yield
3838

tests/integration/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
@fixture
88
def app(environ):
9-
from fastapi_async_sqla import lifespan
9+
from fastsqla import lifespan
1010

1111
app = FastAPI(lifespan=lifespan)
1212
return app

tests/integration/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def setup_tear_down(engine):
1717

1818

1919
async def test_lifespan_reflects_user_table(environ):
20-
from fastapi_async_sqla import Base, lifespan
20+
from fastsqla import Base, lifespan
2121

2222
class User(Base):
2323
__tablename__ = "user"

tests/integration/test_pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async def setup_tear_down(engine, faker):
5656

5757
@fixture
5858
def app(app):
59-
from fastapi_async_sqla import (
59+
from fastsqla import (
6060
Base,
6161
Page,
6262
Paginate,

tests/integration/test_session_dependency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def setup_tear_down(engine):
2424

2525
@fixture
2626
def app(setup_tear_down, app):
27-
from fastapi_async_sqla import Base, Item, Session
27+
from fastsqla import Base, Item, Session
2828

2929
class User(Base):
3030
__tablename__ = "user"

tests/unit/test_lifespan.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33

44
async def test_it_returns_state(environ):
5-
from fastapi_async_sqla import lifespan
5+
from fastsqla import lifespan
66

77
async with lifespan(None) as state:
8-
assert "fastapi_async_sqla_engine" in state
8+
assert "fastsqla_engine" in state
99

1010

1111
async def test_it_binds_an_sqla_engine_to_sessionmaker(environ):
12-
from fastapi_async_sqla import SessionFactory, lifespan
12+
from fastsqla import SessionFactory, lifespan
1313

1414
assert SessionFactory.kw["bind"] is None
1515

@@ -22,7 +22,7 @@ async def test_it_binds_an_sqla_engine_to_sessionmaker(environ):
2222

2323

2424
async def test_it_fails_on_a_missing_sqlalchemy_url(monkeypatch):
25-
from fastapi_async_sqla import lifespan
25+
from fastsqla import lifespan
2626

2727
monkeypatch.delenv("SQLALCHEMY_URL", raising=False)
2828
with raises(Exception) as raise_info:
@@ -33,7 +33,7 @@ async def test_it_fails_on_a_missing_sqlalchemy_url(monkeypatch):
3333

3434

3535
async def test_it_fails_on_not_async_engine(monkeypatch):
36-
from fastapi_async_sqla import lifespan
36+
from fastsqla import lifespan
3737

3838
monkeypatch.setenv("SQLALCHEMY_URL", "sqlite:///:memory:")
3939
with raises(Exception) as raise_info:

0 commit comments

Comments
 (0)