rubydb-python
rubydb-python is a dependency-free Python DB-API 2.0 client for RubyDB
server mode. It connects over RubyDB’s newline-delimited JSON protocol and
supports TLS URLs, authentication, parameterized queries, prepared statements
through the wire protocol, transactions, timeouts with cancellation, and a
bounded connection pool.
It does not open RubyDB embedded .rdb files. An embedded file must have one
Ruby process owner; Python applications use a RubyDB server.
Install
From PyPI after release:
python -m pip install rubydb-python
From this repository during development:
cd adapters/python
python -m pip install -e .
Connect and query
import os
import rubydb
with rubydb.connect(os.environ["RUBYDB_URL"]) as connection:
with connection.cursor() as cursor:
cursor.execute(
"SELECT id, name FROM users WHERE active = ? ORDER BY id",
[True],
)
for row in cursor.fetchall():
print(row)
rubydb:// is plain TCP for trusted private development networks.
rubydbs:// enables TLS. Production should use rubydbs://, peer
verification, a private network, and a secret manager:
rubydbs://app_user:URL_ENCODED_PASSWORD@db.internal:7432/app?verify_peer=true&ca_file=%2Fetc%2Frubydb%2Ftls%2Fca.crt
Passwords and private keys must not be committed or printed. The server and client must use compatible RubyDB protocol versions.
Transactions and pooling
Connections default to DB-API transaction behavior (autocommit=False):
import rubydb
with rubydb.connect("rubydbs://app_user:password@db.internal:7432/app") as db:
with db.cursor() as cursor:
cursor.execute(
"INSERT INTO audit_events (event_name) VALUES (?)",
["python-start"],
)
Prepared statements are available when the RubyDB server advertises them:
with rubydb.connect(os.environ["RUBYDB_URL"]) as db:
statement = db.prepare("SELECT id FROM users WHERE email = ?")
try:
with statement.execute(["ada@example.test"]) as cursor:
print(cursor.fetchone())
finally:
statement.close()
For concurrent Python workers, use a bounded pool. The pool creates at most
max_size server sessions:
from rubydb import ConnectionPool
pool = ConnectionPool(
"rubydbs://app_user:password@db.internal:7432/app",
min_size=1,
max_size=8,
)
try:
with pool.connection() as db:
with db.cursor() as cursor:
cursor.execute("SELECT 1")
print(cursor.fetchone())
finally:
pool.close()
Test and package
Run the dependency-free unit tests:
cd adapters/python
python -m unittest discover -s tests -v
Build and inspect the distribution:
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
Publish only after CI, protocol integration tests against a real RubyDB server, TLS tests, and application validation pass:
python -m twine upload dist/*
Configure PyPI credentials through trusted publishing or a protected token; never put a token in this repository or in a committed shell script.
Compatibility boundary
This is a RubyDB client, not a PostgreSQL driver. It does not provide PostgreSQL SQL compatibility, embedded-mode access, or automatic failover. Use PostgreSQL’s Python drivers for PostgreSQL applications. See the repository’s wire protocol, production operations guide, and SQL compatibility guide.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rubydb_python-0.1.0.tar.gz.
File metadata
- Download URL: rubydb_python-0.1.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
875f852a647f9686f598dafd802709f16f70d79d356300f58b61a4c33403386b
|
|
| MD5 |
3c6191e6230fb55f3004601326a34954
|
|
| BLAKE2b-256 |
441774d88a360277fcfb857daee103c1d11802179f357c86a6166114018dc8eb
|
File details
Details for the file rubydb_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rubydb_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1aa36abeded67ff70d88b4e29976a90a5deba00be90c3af2e8b15b5ba807661
|
|
| MD5 |
2d96a60a56cd27ff3dbd1209053e7f3c
|
|
| BLAKE2b-256 |
4335bc6cd6919ddfec089cdc6fec2c269ebbfd2f6dd2940f3f4e6af4712cc07c
|