SQLAlchemy HawDB
sqlalchemy-hawdb provides a SQLAlchemy 2.x dialect for the embedded HawDB
database. It uses HawDB's own PEP 249 driver and does not add a wire protocol or
duplicate its DBAPI implementation.
Requirements
- Python 3.11 or newer
- HawDB Python binding 0.22.x (CI tests 0.22.0)
- SQLAlchemy 2.x
Install the dialect and its HawDB dependency from PyPI:
python -m pip install sqlalchemy-hawdb
To install this checkout instead:
python -m pip install /path/to/sqlalchemy_hawdb
Connect
Use an absolute database directory path with four slashes:
from sqlalchemy import Column, Integer, MetaData, String, Table, create_engine
engine = create_engine("hawdb:////var/lib/my-app/knowledge")
metadata = MetaData()
records = Table(
"records",
metadata,
Column("id", Integer, primary_key=True, autoincrement=False),
Column("body", String(500), nullable=False),
)
metadata.create_all(engine)
with engine.begin() as connection:
connection.execute(records.insert(), {"id": 1, "body": "Hello HawDB"})
HawDB creates the database directory itself; its parent directory must already exist.
Use hawdb:///:memory: for an in-memory database. Like SQLAlchemy's SQLite
dialect, the in-memory engine keeps one database per thread. Add
?read_only=true to open an existing database read-only.
HawDB connections are thread-affine and hold their database path until closed.
For file databases the dialect uses SQLAlchemy's NullPool: each SQLAlchemy
connection closes its HawDB handle when returned. Do not keep multiple
connections to the same database path open at once or pass a SQLAlchemy
connection between threads. In-memory connections are kept per thread and must
also be used serially within that thread.
Supported behavior
- SQLAlchemy Core and ORM statements using HawDB's relational SQL subset
- Positional
$1,$2, ... binding through HawDB's native DBAPI driver - Explicit SQLAlchemy transactions mapped to HawDB commit and rollback
- Table, column, primary key, unique constraint, and index reflection from
HawDB's
information_schemaandpg_catalogviews - The default
publicschema - HawDB-native scalar DDL types: integer types map to
BIGINT, floating and numeric types toDOUBLE PRECISION, strings toTEXT, and binary values toBYTEA; SQLAlchemy string lengths and numeric precision are not enforced by HawDB
HawDB does not report affected row counts, so DBAPI rowcount is -1 for
statements without a result set. Date and time types compile to TEXT; their
values are encoded and decoded by SQLAlchemy's standard processors.
Auto-generated identity columns, sequences, schema alteration, savepoints, and
concurrent connections to one database path are not supported by this initial
dialect.
Development
Install the project, the HawDB dependency, and the test tools:
python -m pip install -e '.[test]'
python -m pytest
GitHub Actions builds the source distribution and wheel, checks their metadata,
and tests the installed wheel against hawdb==0.22.0 from PyPI on Python
3.11-3.13 for every push and pull request. Missing HawDB wheels fail CI rather
than skipping integration tests or falling back to a source build.
Publishing
.github/workflows/pypi.yaml publishes the tested source distribution and wheel
when a GitHub Release is published. The release tag must match the version in
pyproject.toml, for example v0.22.0. A manual workflow dispatch runs the same
build and tests without uploading to PyPI.
Configure a PyPI Trusted Publisher for the sqlalchemy-hawdb project with:
- Owner:
nowledge-co - Repository:
sqlalchemy-hawdb - Workflow:
pypi.yaml - Environment:
pypi
For the first release, configure a pending publisher in your PyPI account.
The publish job uses GitHub's pypi environment and OIDC; no PyPI API token
secret is required.
Metadata
Release files for sqlalchemy-hawdb 0.22.0
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 |
|---|---|---|---|---|
| sqlalchemy_hawdb-0.22.0.tar.gz | 8.1 kB | With provenance | Details for sqlalchemy_hawdb-0.22.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlalchemy_hawdb-0.22.0-py3-none-any.whl | Python 3 | none | any | Details for sqlalchemy_hawdb-0.22.0-py3-none-any.whl |
Total release size: 14.7 kB
Release files / sqlalchemy_hawdb-0.22.0.tar.gz
| Download URL | sqlalchemy_hawdb-0.22.0.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca425c7a73f6119e9a786ac5dff7d346ea0b3f2a81e1dee231877a06872f5dcd
|
|
BLAKE2b-256 checksum How to use checksums |
9bf4a2faa80be6cbc1b3ba1a52dbc346a38e08c50b26b8e7b259dfeb11cf961f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logRelease files / sqlalchemy_hawdb-0.22.0-py3-none-any.whl
| Download URL | sqlalchemy_hawdb-0.22.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f917b3b53b2e2101d9f179ca8456b17199bb7be766a2606f8478ddead896dac
|
|
BLAKE2b-256 checksum How to use checksums |
322ba0bb1a0f8cc8b9554b952f6ce4cdd0f348395cb5639c1459d537f2449981
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logSecurity for sqlalchemy-hawdb 0.22.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for sqlalchemy_hawdb-0.22.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logA 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.