Async connector for working with the distributed Picodata database.
Project description
Picopyn - Picodata python driver
Picopyn is a Python package for working with the distributed Picodata database. It's built on top of the asyncpg package.
Features
- Connection pooling with configurable pool size
- Optional automatic node discovery
- Pluggable load-balancing strategies
- Fully asynchronous API
Navigation
Install
Install from source:
git clone https://git.picodata.io/solution/picopyn.git
cd picopyn
make install
Quickstart
import asyncio
from picopyn 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 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())
Development
Install development dependencies
pip install -r requirements-dev.txt
Documentation
To update documentation:
make gen-doc
To view documentation:
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
Run the general test suite:
make test
or run SSL tests:
make test-ssl
This will:
-
Start required test containers (Picodata cluster and test-runner) using Docker Compose
-
Execute tests using pytest
How to debug
Do not forget run environment via make env
For debugging purposes:
- Open a bash shell in the test container:
make shell
- For interactive Python (with asyncio support) run inside of container:
python -m asyncio
- To connect directly to Picodata:
picodata admin tmp/picodata-1-1/admin.sock
Benchmark
Benchmark instructions and usage examples are available here.
Project details
Release history Release notifications | RSS feed
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 picopyn-0.2.0.tar.gz.
File metadata
- Download URL: picopyn-0.2.0.tar.gz
- Upload date:
- Size: 483.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b17ffd79502d5bca164c765312a0ef4f3136d1bc1bb40ae52db3ad650a7f9c8a
|
|
| MD5 |
95a917efe9a5dc45901e324e99fde1c2
|
|
| BLAKE2b-256 |
db5f298108a2aade034c3b1158a10c19200579c9f60a723739deaf5f1a955678
|
File details
Details for the file picopyn-0.2.0-py3-none-any.whl.
File metadata
- Download URL: picopyn-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d393c582485c954893b2d861257b523a0ed4778a4e62650b8561947b4c7e88b0
|
|
| MD5 |
95b2edeafcc92ee0c073ed77e30562c1
|
|
| BLAKE2b-256 |
65bd993ec8c8a70f677f085106c720002c41cbe6aa83f6298cc08207839506d9
|