user-registration-sqlalchemy
SQLAlchemy repository adapter for the user-registration Python package.
This package provides a SQLAlchemy 2.x implementation of the repository interfaces required by the framework-agnostic registration service.
It keeps persistence concerns separate from registration business logic.
Features
- SQLAlchemy 2.x repository implementation
- Implements the
UserRepositorycontract fromuser-registration - Async SQLAlchemy support
- User persistence and lookup
- Username/email duplicate detection
- Database constraint error handling
- Compatible with SQLite, PostgreSQL, MySQL and other SQLAlchemy-supported databases
- Framework independent
Installation
Install the core package and SQLAlchemy adapter:
pip install user-registration user-registration-sqlalchemy
Or:
pip install user-registration-sqlalchemy
The adapter declares user-registration and SQLAlchemy as dependencies.
Architecture
The adapter implements the repository boundary defined by the core package:
RegistrationService
│
▼
UserRepository
Protocol
│
▼
SQLAlchemyUserRepository
│
▼
SQLAlchemy 2.x
│
▼
Database
The registration service does not need to know whether the application uses SQLite, PostgreSQL, MySQL, or another supported database.
User Model
The adapter provides a SQLAlchemy user model suitable for persistence.
Conceptually:
User
├── id
├── username
├── email
├── password_hash
└── timestamps / persistence fields
Passwords are stored as password hashes rather than plaintext passwords.
Password hashing itself is handled by the core registration package.
Repository
The primary adapter component is:
SQLAlchemyUserRepository
It implements the core repository contract and provides operations required by the registration service, including:
create()
get_by_username()
get_by_email()
exists_by_username()
exists_by_email()
The exact available methods are determined by the package version.
Example
A typical application can compose the components as follows:
from user_registration import RegistrationService
from user_registration_sqlalchemy import SQLAlchemyUserRepository
repository = SQLAlchemyUserRepository(...)
service = RegistrationService(
repository=repository,
...
)
The application remains responsible for creating and configuring its SQLAlchemy engine/session infrastructure.
Database Independence
Because the adapter uses SQLAlchemy, the same repository architecture can support different databases.
For example:
Development
│
▼
SQLite
Testing
│
▼
PostgreSQL
Production
│
▼
PostgreSQL / MySQL / other SQLAlchemy-supported DB
The registration service does not need to change when the persistence technology changes.
Duplicate Users
The adapter translates database uniqueness violations into the core package's duplicate-user domain error.
For example, a unique constraint on:
username
email
can be mapped to the registration layer rather than exposing SQLAlchemy-specific exceptions to the application.
This allows the application layer to consistently handle duplicate registration:
Database
│
│ IntegrityError
▼
SQLAlchemy Adapter
│
│ DuplicateUserError
▼
RegistrationService
│
▼
Application / API
Transaction Management
The application owns the SQLAlchemy engine/session lifecycle.
The adapter should be integrated into the application's existing transaction management strategy rather than creating an independent application-wide database lifecycle.
This allows applications to control:
- sessions
- transactions
- connection pools
- isolation levels
- database configuration
- migrations
Testing
Run the SQLAlchemy integration tests from the repository root:
.venv/bin/python -m pytest tests/integration/test_sqlalchemy_repository.py -v
Run all tests:
.venv/bin/python -m pytest -v
Development
Install the adapter in editable mode:
.venv/bin/python -m pip install -e "./adapters/sqlalchemy[dev]"
Run Ruff:
.venv/bin/python -m ruff check adapters/sqlalchemy
Check formatting:
.venv/bin/python -m ruff format --check adapters/sqlalchemy
Run MyPy:
.venv/bin/python -m mypy adapters/sqlalchemy
Compatibility
The adapter requires:
- Python
3.12+ - SQLAlchemy
>=2.0,<3.0 user-registration >=0.1.0,<1.0.0
Related Packages
Core package:
FastAPI adapter:
License
MIT License.
Visit https://github.com/ShamimurRahmanShuvo/user_registration/tree/main/docs for more detials.
Release files for user-registration-sqlalchemy 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| user_registration_sqlalchemy-0.1.3.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| user_registration_sqlalchemy-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / user_registration_sqlalchemy-0.1.3.tar.gz
| Download URL | user_registration_sqlalchemy-0.1.3.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4e6b9dbac2ef41faeaed3b7df05ee58114f6b1c3a0f7497025a89588a3ba776
|
|
BLAKE2b-256 checksum How to use checksums |
8d10dbb61b6b43e4da6e6844a87c6519c816da9af12561d0b0071d422b721562
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 25, 2026.
Transparency logRelease files / user_registration_sqlalchemy-0.1.3-py3-none-any.whl
| Download URL | user_registration_sqlalchemy-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e2fd15c1799d97853534011dd9fd51f2f150027e91b1b7c7dbeab14b3f4bb18
|
|
BLAKE2b-256 checksum How to use checksums |
b927a26886074a4e7d374c650324da9ced39a991786ae0d35da1b19db0752c23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 25, 2026.
Transparency log