Skip to main content

san_db_ox

Python client for SanDBox: connect to a running san-db-ox --serve-stdio process, either as a child process (direct-connect) or over a TCP/UNIX socket exposed by something like socat.

pip install san-db-ox-client

(the distribution name is san-db-ox-client; the importable module is san_db_ox, since Python identifiers can't contain hyphens)

protocol number 1

Driver version numbers are not tied to the upstream SanDBox version; the protocol number above is what expresses compatibility. Runtime dependencies: none (standard library only).

Quickstart

import san_db_ox

with san_db_ox.connect("san-db-ox", ["--serve-stdio"]) as c:
    c.exec("CREATE TABLE t(x INTEGER)")
    result = c.query("SELECT x FROM t")

connect takes the command to launch, not a fixed "local" assumption, so the same call works over SSH, through Docker, or via kubectl exec just by changing the command and args -- see docs/usage/connecting.md for worked examples of each.

Connecting over a socket instead

c = san_db_ox.connect_unix("/tmp/sandbox.sock")
# or, for TLS:
sock = ssl_context.wrap_socket(socket.create_connection(("host", 5432)))
c = san_db_ox.connect_socket(sock)

Client (direct-connect) and SocketClient (socket) both implement the Connection protocol (query/exec/snapshot/load/inspect/tables/ schema/dump/close). overwrite and exit_code are only on Client -- they don't mean anything over a socket connection, so they're simply not there to call.

Connecting anywhere

For direct-connect over SSH/Docker/Kubernetes, socat with TLS client authentication, and source-IP restriction, see docs/usage/connecting.md (a Japanese version is also available at docs/usage/connecting_ja.md).

Testing

make fetch        # downloads the san-db-ox binary tests run against into bin/
make python-test   # unit tests plus an integration suite against that binary

Set SAN_DB_OX_BIN to point at a locally built san-db-ox binary instead of downloading one.

License

MIT. See LICENSE.

Release files for san-db-ox-client 0.1.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 san-db-ox-client 0.1.0
File Size Uploaded
san_db_ox_client-0.1.0.tar.gz 24.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for san-db-ox-client 0.1.0
File Interpreter ABI Platform
san_db_ox_client-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 38.7 kB

Release files / san_db_ox_client-0.1.0.tar.gz

Download URL san_db_ox_client-0.1.0.tar.gz
Size 24.4 kB
Tags Source
SHA-256 checksum
How to use checksums
85c4764f2c903cd2ed89abb5f64c53fae1473a5e0087be0571165f404fc32d19
BLAKE2b-256 checksum
How to use checksums
16ae1479e3e8f534e63a30b6aa2a628978be2275ee79e04711abdd0d9c0a744f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release files / san_db_ox_client-0.1.0-py3-none-any.whl

Download URL san_db_ox_client-0.1.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55e88afedb4d59c5e976085f67f6c6eef0a3440e4e5bf9cd64b5bf05379ce5d3
BLAKE2b-256 checksum
How to use checksums
e5958896ec4ec0bb51fe31b088e72c757baa033f65c807a0739bba01b5d02418
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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