alt-python-boot-pynosqlc
Spring Boot-style CDI auto-configuration for document stores via
pynosqlc. Provides
ManagedNosqlClient, ConfiguredClientDataSource, and a CDI auto-configuration
factory that wires a connected NoSQL client into a Boot application from a
single config property.
Part of the alt-python/boot monorepo.
Quick Start
uv add alt-python-boot-pynosqlc # or: pip install alt-python-boot-pynosqlc
# invoke.py
import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))
import pynosqlc.memory # registers the memory driver
from boot import Boot
from cdi import Context, Singleton
from boot_pynosqlc import pynosqlc_auto_configuration
from services import NoteRepository, Application
Boot.boot({
'contexts': [
Context(pynosqlc_auto_configuration()),
Context([Singleton(NoteRepository), Singleton(Application)]),
]
})
// config/application.json
{
"boot": {
"nosql": {
"url": "pynosqlc:memory:"
}
}
}
Boot reads config/application.json, connects to the NoSQL backend, and injects
a ready ManagedNosqlClient into the application.
What's Included
| Class / Function | Description |
|---|---|
ConfiguredClientDataSource |
CDI bean that reads boot.nosql.* config and creates a ClientDataSource |
ManagedNosqlClient |
CDI bean wrapping the NoSQL client; provides get_collection() |
NoSqlClientBuilder |
Fluent builder for secondary NoSQL clients |
pynosqlc_auto_configuration() |
Returns 2 CDI Singletons ready for Context() |
pynosqlc_starter() |
Alias for pynosqlc_auto_configuration() |
pynosqlc_boot() |
One-call Boot.boot() entry point |
DEFAULT_NOSQL_PREFIX |
'boot.nosql' |
Configuration
All properties are under boot.nosql by default (override with a custom prefix).
| Property | Type | Default | Description |
|---|---|---|---|
boot.nosql.url |
string | — | pynosqlc URL, e.g. pynosqlc:memory: |
boot.nosql.username |
string | — | Username (optional) |
boot.nosql.password |
string | — | Password (optional) |
If boot.nosql.url is absent, the ConfiguredClientDataSource bean is still
registered but its _delegate is None. Calling get_collection() will raise
RuntimeError('NoSQL client not ready'). This lets you deploy with an optional
NoSQL client without breaking CDI wiring.
Install
uv add alt-python-boot-pynosqlc # or: pip install alt-python-boot-pynosqlc
Requires Python 3.12+, alt-python-boot-lib, alt-python-pynosqlc-core, and
alt-python-pynosqlc-memory. All dependencies are available on PyPI.
Working with Collections
ManagedNosqlClient.get_collection(name) is synchronous. All collection
operations are async — use asyncio.run() to bridge from synchronous CDI
lifecycle methods:
import asyncio
class NoteRepository:
def __init__(self):
self.nosql_client = None # CDI-autowired
async def find_all(self):
col = self.nosql_client.get_collection('notes') # sync
cursor = await col.find({'type': 'and', 'conditions': []})
return cursor.get_documents() # synchronous — do NOT await
async def store(self, key, note):
col = self.nosql_client.get_collection('notes')
await col.store(key, note)
class Application:
def __init__(self):
self.note_repository = None # CDI-autowired
def run(self):
# CDI calls run() synchronously — bridge to async here
asyncio.run(self._run_async())
async def _run_async(self):
await self.note_repository.store('k1', {'title': 'First', 'done': False})
notes = await self.note_repository.find_all()
for note in notes:
print(note['title'])
Collection API
| Method | Signature | Description |
|---|---|---|
store |
async (key, doc) → None |
Insert or replace a document by key |
get |
async (key) → dict | None |
Retrieve a document; None if absent |
insert |
async (doc) → str |
Insert and return an auto-assigned ID |
update |
async (key, patch) → None |
Merge patch into an existing document |
delete |
async (key) → None |
Remove a document |
find |
async (filter) → Cursor |
Query with a filter; returns a Cursor |
Cursor.get_documents() is synchronous — it returns a plain list and must
not be awaited:
cursor = await col.find(filter)
docs = cursor.get_documents() # not: await cursor.get_documents()
Secondary NoSQL Clients
NoSqlClientBuilder creates a second set of CDI beans with a custom config
prefix and custom bean names:
from boot_pynosqlc import NoSqlClientBuilder, pynosqlc_auto_configuration
from cdi import Context
primary = pynosqlc_auto_configuration() # boot.nosql.url
secondary = (
NoSqlClientBuilder.create()
.prefix('myapp.reporting')
.bean_names({
'nosql_client_data_source': 'reporting_ds',
'nosql_client': 'reporting_client',
})
.build()
)
ctx = Context([*primary, *secondary, ...])
Config for the secondary client lives under myapp.reporting.*:
{
"myapp": {
"reporting": {
"url": "pynosqlc:memory:"
}
}
}
Using with Boot
pynosqlc_auto_configuration()
Returns a flat list of 2 Singleton beans. Concatenate with your application
beans and pass to Context():
from boot import Boot
from cdi import Context, Singleton
from boot_pynosqlc import pynosqlc_auto_configuration
Boot.boot({
'contexts': [
Context(pynosqlc_auto_configuration()),
Context([Singleton(MyService), Singleton(MyApp)]),
]
})
pynosqlc_boot()
One-call entry point for applications that need only a single NoSQL client:
from boot_pynosqlc import pynosqlc_boot
from cdi import Context, Singleton
pynosqlc_boot({
'contexts': [Context([Singleton(MyService), Singleton(MyApp)])],
})
CDI Lifecycle Notes
ManagedNosqlClient uses synchronous CDI lifecycle methods (init(),
destroy()) with asyncio.run() as a bridge to the async pynosqlc client:
init()callsasyncio.run(self._connect())to establish the client connection.destroy()callsasyncio.run(self._client.close())for clean shutdown.
CDI's SIGINT handler calls destroy() synchronously. Do not override destroy()
as async def — the coroutine will never be awaited and Python will emit
RuntimeWarning: coroutine was never awaited.
Running Tests
uv run pytest packages/boot-pynosqlc -v
License
MIT
Metadata
Release files for alt-python-boot-pynosqlc 1.1.1
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 | |
|---|---|---|---|---|
| alt_python_boot_pynosqlc-1.1.1.tar.gz | 5.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| alt_python_boot_pynosqlc-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.0 kB
Release files / alt_python_boot_pynosqlc-1.1.1.tar.gz
| Download URL | alt_python_boot_pynosqlc-1.1.1.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2e536d84ea57df15587e6cb4c3fdbd02a1e5331b07a3d8b145bdd7058ef5853
|
|
BLAKE2b-256 checksum How to use checksums |
13d8e47bcd363bf1648da9cb690bcb022205e3dd6d9fca53a610d02107e4eb27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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 / alt_python_boot_pynosqlc-1.1.1-py3-none-any.whl
| Download URL | alt_python_boot_pynosqlc-1.1.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4137547f7f70024db43a46d1edc119c81697c62690c30076380fbe877c933231
|
|
BLAKE2b-256 checksum How to use checksums |
74a528e6123b4458947231aa313a98ae37858d39c57d8cae84e9e25d4ba4924d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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}
|
Security for alt-python-boot-pynosqlc 1.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.