Skip to main content

bolinette-data

The Bolinette data extension: a relational layer built on SQLAlchemy.

It reads the databases from the application configuration, binds each declarative base to one of them, and registers a Repository and a Service for every entity it finds. The injector scope is the unit of work, so a transaction opens when a scope first needs a session and commits when that scope closes.

from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column

from bolinette.data.relational import declarative_base


@declarative_base("default")
class Base(DeclarativeBase):
    pass


class Example(Base):
    __tablename__ = "examples"

    id: Mapped[int] = mapped_column(primary_key=True)
    name: Mapped[str]

Installation

$ pip install bolinette-data  # or use your preferred package manager

Requirements

Bolinette-data requires Python 3.13 (or newer), and depends on bolinette and SQLAlchemy. The driver of a database is imported only when a connection is configured for it, so an application using SQLite never needs the PostgreSQL driver installed.

What the data extension does

  • Connections from configuration — the data.databases section lists them by name, url and echo flag. The url scheme picks the system: synchronous and asynchronous SQLite and PostgreSQL come bundled, and database_system registers another.
  • Entities without a decorator — a declarative base is bound to a connection with declarative_base, and every mapped class of that base is an entity.
  • Repository — the data access layer, with find_all, get_by_primary, first, iterate, add, delete and flush. iterate takes any SQLAlchemy statement, so a complex query stays a SQLAlchemy query.
  • Service — the layer between the repository and your application, where business logic goes. create and update take a payload, map it onto the entity, then check that no non-nullable column was left empty.
  • Your own implementations — a subclass decorated with repository() or service() replaces the default for that entity.
  • Unit of work — AsyncTransaction is entered and exited by the injector scope, committing on success and rolling back on error. Sessions open lazily, one per engine.
  • Table creation — in-memory databases are created at startup, and blnt db init creates the tables of every other connection.

License

Bolinette is released under the MIT license, see LICENSE.txt.

Metadata

Release files for bolinette-data 0.20.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bolinette-data 0.20.0
File Size Uploaded
bolinette_data-0.20.0.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bolinette-data 0.20.0
File Interpreter ABI Platform
bolinette_data-0.20.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 kB

Release files / bolinette_data-0.20.0.tar.gz

Download URL bolinette_data-0.20.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1164eba418c369c29ea69f982e1ac8f5502d3f31f9389659daa334f2283423e3
BLAKE2b-256 checksum
How to use checksums
d53b7f4f920a68799efa84fef377325aa136614e3e3ce9dde79473739d4507d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / bolinette_data-0.20.0-py3-none-any.whl

Download URL bolinette_data-0.20.0-py3-none-any.whl
Size 19.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ade2a0c0cd3077c27f72887042ecf9dd71091e8ca7e771eaa8a8e20fa2b468f6
BLAKE2b-256 checksum
How to use checksums
45567bcd79c2efc87f519fa8e264c86bd81d7be05ba980febb99db5906df72c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.20.0 This release

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.15.4

2 release files

0.15.3

2 release files

0.15.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page