Configuration options¶
This page documents all configuration options for zodb-pgjsonb, including ZConfig directives, Python constructor parameters, S3 deployment modes, and dependencies.
ZConfig <pgjsonb> section¶
The storage is configured in zope.conf via a <pgjsonb> section after
importing the package:
%import zodb_pgjsonb
<zodb_db main>
<pgjsonb>
dsn dbname=zodb host=localhost port=5432 user=zodb password=zodb
</pgjsonb>
</zodb_db>
The factory class is zodb_pgjsonb.config.PGJsonbStorageFactory.
It implements ZODB.storage.
Configuration keys¶
Key |
Type |
Default |
Required |
Description |
|---|---|---|---|---|
|
string |
– |
yes |
PostgreSQL connection string in libpq |
|
string |
|
no |
Storage name, used in sort keys. |
|
boolean |
|
no |
Enable history-preserving mode. |
|
string |
(auto-created tempdir) |
no |
Directory for temporary blob files. Auto-created if omitted. |
|
integer |
|
no |
Size of the per-instance object cache in megabytes. Caches |
|
integer |
|
no |
Minimum number of connections in the instance connection pool. Set to |
|
integer |
|
no |
Maximum number of connections in the instance connection pool. |
|
float |
|
no |
Connection pool acquisition timeout in seconds. Raises |
|
byte-size |
|
no |
Blobs larger than this value are stored in S3 when S3 is configured. Blobs smaller than this remain in PostgreSQL bytea. Set to |
|
string |
– |
no |
S3 bucket name for large blob storage. If omitted, all blobs are stored in PostgreSQL bytea. |
|
string |
|
no |
S3 key prefix for namespace isolation. |
|
string |
– |
no |
S3 endpoint URL for MinIO, Ceph, or other S3-compatible stores. |
|
string |
– |
no |
AWS region name. |
|
string |
– |
no |
AWS access key ID. Uses the boto3 credential chain if omitted. |
|
string |
– |
no |
AWS secret access key. Uses the boto3 credential chain if omitted. |
|
boolean |
|
no |
Enable SSL for S3 connections. |
|
string |
(falls back to |
no |
Local cache directory for S3 blobs. Recommended for production to avoid repeated S3 downloads. |
|
byte-size |
|
no |
Maximum size of the local blob cache directory. |
Python constructor¶
PGJsonbStorage accepts the following parameters:
PGJsonbStorage(
dsn: str,
name: str = "pgjsonb",
history_preserving: bool = False,
blob_temp_dir: str | None = None,
cache_local_mb: int = 16,
pool_size: int = 1,
pool_max_size: int = 10,
pool_timeout: float = 30.0,
s3_client: S3Client | None = None,
blob_cache: S3BlobCache | None = None,
blob_threshold: int = 102_400,
)
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
– |
PostgreSQL connection string. |
|
|
|
Storage name. |
|
|
|
Enable history-preserving mode. |
|
|
|
Blob temp directory. A temporary directory is auto-created when |
|
|
|
Per-instance LRU cache size in megabytes. |
|
|
|
Minimum pool connections. |
|
|
|
Maximum pool connections. |
|
|
|
Pool acquisition timeout in seconds. |
|
|
|
S3 client instance from |
|
|
|
Local S3 blob cache instance from |
|
|
|
Byte threshold for S3 tiering. |
The ZConfig factory (PGJsonbStorageFactory) constructs S3Client and
S3BlobCache from the ZConfig keys before passing them to the constructor.
S3 deployment modes¶
Mode |
Configuration |
Blob behavior |
|---|---|---|
PG-only |
|
All blobs stored as PostgreSQL bytea in |
Tiered |
|
Blobs smaller than threshold stored in PG bytea; blobs at or above threshold stored in S3 with key in |
S3-only |
|
All blobs stored in S3. |
Dependencies¶
Required¶
Package |
Purpose |
|---|---|
|
ZODB framework. |
|
Rust/PyO3 pickle-to-JSON transcoder. |
|
PostgreSQL adapter with connection pooling. |
|
Interface declarations. |
|
Transaction management. |
|
Configuration file parsing. |
Optional¶
Package |
Extra |
Purpose |
|---|---|---|
|
|
S3 client and blob cache for tiered blob storage. |
|
|
AWS SDK for S3 access. |
Install S3 support with pip install zodb-pgjsonb[s3].