Skip to main content

PacificDB

PacificDB Python client

This source package is 1.2.0. Public RC.2 packages remain 1.2.0rc2; they do not contain all current source changes. Use the wheel/source distribution from your selected release. Install pacificdb==1.2.0 from PyPI only after that version is confirmed published.

A database-first client for the Community engine. Requires Python 3.10 or later; no runtime dependencies. The examples use public APIs available in this version.

Start a PacificDB server, then connect to a database directly:

import os
from pacificdb import PacificDB, PacificDBError

url = os.environ.get('PACIFICDB_URL', 'pacificdb://localhost:9000/app')
with PacificDB.connect(url) as db:
    db.create_database()             # create the URL's database and select it
    db.create_collection('users')
    db.insert('users', {'id': '1', 'name': 'Ada'})
    print(db.find_one('users', {'id': '1'}))
    db.update_one('users', {'id': '1'}, {'$set': {'name': 'Grace'}})
    print(db.count('users'))

Create calls are not implicit or idempotent: omit them when the database or collection already exists. No project or separate selection call is required. The existing PacificDBClient(host, port, user_id, database, use_tls, ca_file, timeout) constructor still works. PacificDB is its shorter alias.

connect(url, **options) eagerly authenticates URL credentials and checks the connection with ping; from_url(url, **options) connects lazily on the first request. URL credentials must contain both username and password. Use an environment variable for private URLs, not a literal in source or logs. Use pacificdbs:// for TLS with verified hostname and default trust, or provide ca_file='/path/to/ca.pem'. Authentication on plain TCP does not encrypt traffic.

URL defaults: port 9000, user system, 30-second deadline, pool size 16. Query keys are userId, timeoutMs, poolSize, caFile; duplicate/unknown keys and conflicting explicit options fail before connecting. Python options use user_id, timeout (seconds), pool_size, ca_file. Pools are limited to 32; responses default to a 64 MiB limit (max_response_bytes can lower it). Idle connections are reused only when the engine explicitly advertises keepalive.

Database methods: create_database(name=None, db_type='binary'), list_databases(), use_database(name), drop_database(name=None). Creation selects on success; switching checks the engine's authorized listing. Failed create/switch/drop calls preserve selection; dropping the selected database clears it. create_collection, list_collections, and drop_collection operate on the selected database.

Document methods: insert, insert_many, find, find_one, count, aggregate, explain, update_one, update_many, delete_one, delete_many, bulk_write. find(collection, filter=None, limit=-1, offset=0) returns the original engine response; find_one returns the first document or None. list_databases returns a list of names. Other methods preserve protocol responses, including partial bulk results. Use capabilities() for the server's feature report, and request({...}) for raw protocol access. The engine remains responsible for namespace rules and authorization.

Every operation snapshots selected scope and caller JSON before network I/O. Do not mutate input while the method itself is copying it. Selection is shared client state; use separate clients when independent concurrent selection is needed. A completed drop cannot clear a newer selection of another database.

PacificDBError preserves .code and a sanitized .response. Known credentials are redacted from error diagnostics. Successful document values are unchanged. A disconnect/timeout after sending a write can have an unknown outcome: writes are never silently retried. The deadline covers pool waiting and socket I/O; OS DNS resolution can exceed it. close() is idempotent and wakes queued calls; always use a context manager or close explicitly.

Before reusing an idle connection, the pool retires sockets with buffered input or an observable close. This happens before dispatch, without replaying a sent command. A close racing the dispatch still returns an explicit unknown-outcome error. Healthy TCP/TLS connections remain reusable.

Media and backups

from pathlib import Path

# Small in-memory attachments; normal collection documents.
db.media.put('assets', 'logo', b'\x00\xff', {'contentType': 'image/png'})
attachment = db.media.get('assets', 'logo')  # data: bytes, metadata: dict

# Files are hashed and transferred in bounded chunks.
manifest = db.media.upload_file('assets', Path('video.mp4'))
db.media.download_file(manifest['id'], Path('download.mp4'), collection='assets')
backup = db.backups.create(description='before maintenance')
db.backups.export(backup['backup_id'], Path('backup.json'))

On interrupted uploads, catch MediaUploadError and inspect upload_id, next_chunk, received_chunks, received_bytes and resumable. Resume explicitly with the same file, collection and chunk setting: db.media.upload_file('assets', path, resume=error.upload_id). A lost acknowledgement can mean a chunk was stored; resume asks the server which chunks exist and skips them. It never replays a write automatically.

Uploads reject empty/nonregular files and changed content. File downloads require a selected database and validate the returned database/optional collection, chunk sizes/indexes/base64/SHA-256 and whole file. Downloads and backup exports write a private unique sibling temporary file, then replace the destination only after verification. The parent directory must exist. Backup export streams the existing pacificdb-full-backup-v1 JSON format; it is not an engine restore API. Filesystem errors are typed errors. Each network call has a deadline; an entire multi-chunk transfer has no single overall deadline. In-memory attachments allocate the supplied bytes; use the file APIs for large media.

Apache-2.0. Stable-release and registry qualification remain separate.

Advanced named operations and wire aliases are documented in SDK capabilities.

Metadata

Release files for pacificdb 1.2.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 pacificdb 1.2.0
File Size Uploaded Provenance Actions
pacificdb-1.2.0.tar.gz 35.0 kB With provenance Details for pacificdb-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pacificdb 1.2.0
File Interpreter ABI Platform Actions
pacificdb-1.2.0-py3-none-any.whl Python 3 none any Details for pacificdb-1.2.0-py3-none-any.whl

Total release size: 58.6 kB

Release files / pacificdb-1.2.0.tar.gz

Download URL pacificdb-1.2.0.tar.gz
Size 35.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2599ef04affa11c3414517459044f9bdb7c390d170f04313549cf510f476548c
BLAKE2b-256 checksum
How to use checksums
bab7514923672b318bec591c90721a835aa349d1cad87684127d5967792e8fce
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 Nov 8, 2026.

Transparency log

Release files / pacificdb-1.2.0-py3-none-any.whl

Download URL pacificdb-1.2.0-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78ed0877c05c6914ba654dcf1de75934e338424cbbd811a589ad8dbbbffbbeb0
BLAKE2b-256 checksum
How to use checksums
9e07371dc522fd03278c3832279942be7be74cd89ea1ec1b59e1f788ee703eba
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 Nov 8, 2026.

Transparency log

Security for pacificdb 1.2.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pacificdb-1.2.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 Nov 8, 2026.

Transparency log

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.

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