Metadata-Version: 2.5
Name: narabi-orm
Version: 0.1.0
Summary: An asynchronous Active Record ORM for Python.
Project-URL: Homepage, https://github.com/RickBarretto/narabi-orm
Project-URL: Documentation, https://github.com/RickBarretto/narabi-orm/tree/main/docs
Project-URL: Repository, https://github.com/RickBarretto/narabi-orm
Project-URL: Issues, https://github.com/RickBarretto/narabi-orm/issues
License-Expression: BSD-3-Clause
License-File: LICENSE
Keywords: active-record,async,orm,postgresql,sqlite
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: AsyncIO
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: attrs>=23.2
Requires-Dist: cattrs>=24.1
Requires-Dist: cyclopts<5,>=4
Provides-Extra: all
Requires-Dist: aiosqlite; extra == 'all'
Requires-Dist: ipython<10,>=9; extra == 'all'
Requires-Dist: psycopg-pool; extra == 'all'
Requires-Dist: psycopg[binary]; extra == 'all'
Provides-Extra: console
Requires-Dist: ipython<10,>=9; extra == 'console'
Provides-Extra: postgres
Requires-Dist: psycopg-pool; extra == 'postgres'
Requires-Dist: psycopg[binary]; extra == 'postgres'
Provides-Extra: sqlite
Requires-Dist: aiosqlite; extra == 'sqlite'
Provides-Extra: test
Requires-Dist: aiosqlite; extra == 'test'
Requires-Dist: ipython<10,>=9; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Description-Content-Type: text/markdown

# Narabi

Narabi is an async Active Record library for Python. Declare a model with ordinary type annotations, then create, query, and update rows through that model. Use SQLite for a local project or PostgreSQL for a service.

```python
from narabi import Increment, Primary, table

@table
class Book:
    id: Primary[int] = Increment()
    title: str

book = await Book.create(title="A Wizard of Earthsea")
saved = await Book.require(book.id)
```

The example assumes a project scaffolded with `narabi init` and a migrated `books` table. Narabi infers `books` from `Book`. The [bookstore tutorial](docs/tutorial.md) builds both from a clean directory.

## Privacy belongs in the model

A bookstore needs a customer's contact details. Its logs and JSON responses rarely need all of them.

```python
from narabi import Personal, Private, Sensitive, record

@record
class CustomerContact:
    email: Personal[str]
    access_token: Private[Sensitive[str]]

contact = CustomerContact(email="reader@example.test", access_token="demo-token")
print(contact)
# CustomerContact(email=<redacted>, access_token=<redacted>)
print(contact.to_dict())
# {'email': 'reader@example.test'}
```

All three markers redact values in record representations. `Private` also omits the field from default serialization. `narabi privacy inventory` lists classifications from configured models without reading stored rows. If the record lives in a configured module named `models`, the inventory includes:

```text
models.CustomerContact.email: Personal
models.CustomerContact.access_token: Private, Sensitive
```

See [Privacy and serialization](docs/guides.md#privacy-and-serialization).

## From a model to a running app

- Generate an editable Python migration, review the changes, and apply it. Render SQL offline or load a versioned schema snapshot. [Migration workflows](docs/guides.md#migrations-and-recovery)
- Compose queries, load associations, and inspect SQL and query plans. [API reference](docs/reference.md)
- Try a write in `narabi console --sandbox` and see it in the next cell. Exit to roll it back. [Console guide](docs/guides.md#console)
- Use the same models in a [FastAPI app](docs/fastapi.md) or a [Flask app](docs/flask.md).

## How it fits

| Library | Where persistence lives |
| --- | --- |
| Narabi | Async operations on Python models, with a `Database` for connections and explicit transactions |
| Rails Active Record | Persistence and queries on Ruby models within the Rails conventions |
| SQLModel | Typed Python models based on Pydantic and SQLAlchemy, with persistence through a session |
| SQLAlchemy ORM | Mapped Python classes, SQL expressions, and a session that manages a unit of work |

[Compare the same bookstore operations](docs/comparisons.md) · [Why Narabi exists](PITCH.md) · [Documentation](docs/README.md) · [Contributing](CONTRIBUTING.md)

Narabi is released under the [BSD 3-Clause License](LICENSE).
