Skip to main content

Version Supported Versions Documentation

Picopyn - Picodata Python driver

Picopyn is a Python package for working with the distributed Picodata database.

Version compatibility:

Picodata version Status
>=25.4.x, < 26.2.x ✅ Fully supported
26.2.x ⚠️ Not yet tested

Features

  • Connection pooling with configurable pool size
  • Optional automatic node discovery
  • Pluggable load-balancing strategies
  • Provides both asynchronous API (based on asyncpg) and synchronous DPAPI-compatible API (based on psycopg)

Navigation

Installation

pip install picopyn

Or from source:

git clone https://git.picodata.io/solution/picopyn.git
cd picopyn
pip install -e .

Quickstart

Async:

import asyncio
from picopyn.asynchronous import Client

async def main():
    # create and connect client to the picodata cluster
    client = Client(dsn="postgresql://admin:pass@localhost:5432")
    await client.connect()

    # execute DDL operations
    await client.execute('''
        CREATE TABLE "warehouse" (id INTEGER NOT NULL, item TEXT NOT NULL, PRIMARY KEY (id)) USING memtx DISTRIBUTED BY (id) OPTION (TIMEOUT = 3.0);
    ''')

    # execute DML/DQL operations
    await client.execute('INSERT INTO "warehouse" VALUES ($1::int, $2::varchar)', 1, "test")
    rows = await client.fetch('SELECT * FROM "warehouse"')
    print(rows)

    await client.close()

asyncio.run(main())

Sync:

from picopyn.synchronous import connect

# create and connect to the picodata cluster
conn = connect("postgresql://admin:pass@localhost:5432")
cur = conn.cursor()

# execute DDL operations
cur.execute('''
    CREATE TABLE "warehouse" (id INTEGER NOT NULL, item TEXT NOT NULL, PRIMARY KEY (id)) USING memtx DISTRIBUTED BY (id) OPTION (TIMEOUT = 3.0);
''')

# execute DML/DQL operations
cur.execute('INSERT INTO "warehouse" VALUES (%s, %s)', (1, "test"))
cur.execute('SELECT * FROM "warehouse"')
print(cur.fetchall())

conn.close()

Development

For development we use uv as package manager and docker compose for test environment.

To install development dependencies:

uv sync --extra test

Inside the test container, run the same command to keep dependencies up to date if the image is outdated:

make shell
# inside the container:
make install

Documentation

The documentation is written in Markdown and built with MkDocs using the Material theme. API reference is generated automatically from docstrings via mkdocstrings.

Published documentation is available at picopyn.readthedocs.io.

Source files are located in the docs/ directory. To work on docs locally, install the docs dependencies and start the live-reload server:

uv sync --extra docs
make doc

How to write code

We use several tools to ensure code style and type safety.

  • ruff — code style, lint checks and automatic lint fixing
  • mypy — static type checking
  • black — code formatting

To check code style and static types:

make lint

To automatically fix formatting and style issues:

make fmt

How to test

We use docker compose for test environment.

Run the general test suite:

make test

or run SSL tests:

make test-ssl

This will:

  1. Start required test containers (Picodata cluster and test-runner) using Docker Compose

  2. Execute tests using pytest

How to debug

Do not forget to run the environment via make env

For debugging purposes:

  1. Open a bash shell in the test container:
make shell
  1. For interactive Python (with asyncio support) run inside of container:
python -m asyncio
  1. To connect directly to Picodata:
picodata admin tmp/data/picodata-1-1/admin.sock

Benchmark

Benchmark instructions and usage examples are available here.

Metadata

Release files for picopyn 1.0.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 picopyn 1.0.0
File Size Uploaded Provenance Actions
picopyn-1.0.0.tar.gz 442.2 kB Without provenance Details for picopyn-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 483.7 kB

Release files / picopyn-1.0.0.tar.gz

Download URL picopyn-1.0.0.tar.gz
Size 442.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e718e34486ddcdfff834e0e76cb6c043e0e7f64a4fdd87b68f3f946dce2af6ab
BLAKE2b-256 checksum
How to use checksums
b2ebd7992f9f771c78f18f705a11e50ed12de0ec181b5127c5a883d0db02d900
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / picopyn-1.0.0-py3-none-any.whl

Download URL picopyn-1.0.0-py3-none-any.whl
Size 41.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aac7a6af625875ae3dc2f99687fea0045e9173f593e594b00c26755ed818fc73
BLAKE2b-256 checksum
How to use checksums
e71f787b91674129451256ffb52eb019f7964388f469f86ef733f617c0fe9100
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for picopyn 1.0.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.

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.

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