Skip to main content

OriginChainDB for Python

The client for OriginChainDB: SQL, graph, vector and full-text search over one HTTP API. It needs Python 3.10 or later.

Install

pip install originchaindb

Connect

You need your database's endpoint, its tenant id and an API key. All three are in the OriginChain console, in your database's connection details.

import os

import originchaindb as oc

config = oc.Configuration(host="https://your-database-endpoint", access_token=os.environ["ORIGINCHAIN_API_KEY"])
tenant = "your-tenant-id"

SQL

with oc.ApiClient(config) as client:
    result = oc.SqlApi(client).sql_exec(
        tenant, oc.SqlExecRequest(sql="SELECT id, name FROM people WHERE id = $1", params=["bob"]))
    print(result.columns, result.rows)

params binds $1, $2, … in order. A NULL cell is an absent key, so read cells by name against columns.

Graph

with oc.ApiClient(config) as client:
    # One-hop neighbours of a node along a relation: their primary keys.
    managers = oc.GraphApi(client).graph_neighbors(tenant, "public.people", "reports_to", "bob")
with oc.ApiClient(config) as client:
    # The k stored vectors nearest to a query vector, best match first: each has .id and .score.
    nearest = oc.VectorApi(client).vector_topk(
        tenant, "doc_vectors", oc.VectorTopkRequest(query=[0.12, 0.98, 0.05], k=5, dim=3))
with oc.ApiClient(config) as client:
    # The ids of the documents whose `body` field matches.
    ids = oc.FtsApi(client).fts_search(tenant, "docs", "body", "vectors")

Errors and request ids

A failed call raises oc.ApiException. Its request_id is the database's id for that request. Quote it when you report a problem.

try:
    with oc.ApiClient(config) as client:
        oc.SqlApi(client).sql_exec(tenant, oc.SqlExecRequest(sql="SELECT * FROM missing"))
except oc.ApiException as e:
    print(e.status, e.request_id)

Diagnostics (off by default)

You can opt in to send call diagnostics to your own database. They contain the method, the path, the outcome, the timing, the status and the request ids, and never SQL, parameters, row data, search text or error messages. Queued diagnostics are sent at interpreter exit (for at most 2 seconds), or when you call flush_diagnostics().

oc.enable_diagnostics(config)

More

Every endpoint is documented at originchain.ai/docs.

License

MIT

Metadata

Release files for originchaindb 0.1.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for originchaindb 0.1.24
File Size Uploaded Provenance Actions
originchaindb-0.1.24.tar.gz 206.3 kB Without provenance Details for originchaindb-0.1.24.tar.gz

Built distribution (wheel)

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

Total release size: 700.3 kB

Release files / originchaindb-0.1.24.tar.gz

Download URL originchaindb-0.1.24.tar.gz
Size 206.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f9539c69560129678e1ecd9fbce7687ff0222cd505fed6ded489e5f890180b35
BLAKE2b-256 checksum
How to use checksums
e3a78dcf65398eca1bedac77a80ad6086d2abc1c1265350d7fa73c7ca9734f29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release files / originchaindb-0.1.24-py3-none-any.whl

Download URL originchaindb-0.1.24-py3-none-any.whl
Size 494.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86f4add19fb7d55f11a75f0ab69037334eecc8ddc8108fd4fcb46892d6944bd5
BLAKE2b-256 checksum
How to use checksums
f3b37c33e93705c8a9b41862977ee8d9dc7139f299dc875d3cee76158e46bc71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Security for originchaindb 0.1.24

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.

Release history Release notifications | RSS feed

This release

0.1.24 This release

2 release files No provenance

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