Tonbo Python Binding
Project description
Tonbo Python Binding
This package intends to build a native python binding for Tonbo.
Tonbo's Python bindings can be used to build data-intensive applications, including other types of databases.
Example
from tonbo import DbOption, Column, DataType, Record, TonboDB, Bound
from tonbo.fs import from_filesystem_path
import asyncio
import os
# define a Tonbo record
@Record
class User:
age = Column(DataType.Int8, name="age", primary_key=True)
height = Column(DataType.Int16, name="height", nullable=True)
weight = Column(DataType.Int8, name="weight", nullable=False)
async def main():
if not os.path.exists("db_path/users"):
os.makedirs("db_path/users")
db = TonboDB(DbOption(from_filesystem_path("db_path/users")), User())
await db.insert(User(age=18, height=175, weight=60))
record = await db.get(18)
assert record == {"age": 18, "height": 175, "weight": 60}
txn = await db.transaction()
txn.insert(User(age=19, height=195, weight=75))
result = await txn.get(19)
assert result == {"age": 19, "height": 195, "weight": 75}
# commit transaction
await txn.commit()
txn = await db.transaction()
# range scan, supports pushing down and limit
scan = await txn.scan(
Bound.Excluded(18), None, limit=100, projection=["age", "weight"]
)
async for record in scan:
print(record)
asyncio.run(main())
See examples for more information.
Roadmap
- Remote storage API mapping and test
- Integrate with other Arrow analytical tools
Development
This assumes that you have Rust and cargo installed. We use the pyo3 to generate a native Python module and use maturin to build Rust-based Python packages.
First, follow the commands below to build a new Python virtualenv, and install maturin into the virtualenv using Python's package manager, pip:
# setup virtualenv
python -m venv .env
# activate venv
source .env/bin/activate
# install maturin
pip install maturin
# build bindings
maturin develop
Whenever Rust code changes run:
maturin develop
Run tests:
maturin develop -E test
python -m pytest
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 Distributions
File details
Details for the file tonbo-0.1.0.tar.gz
.
File metadata
- Download URL: tonbo-0.1.0.tar.gz
- Upload date:
- Size: 5.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8d9344b96fd08be48fa9316a306451e6e6ceb32b52f0411019f71f0fdfb375f |
|
MD5 | a7529fceaa73ded320bd2e1adcb8faaf |
|
BLAKE2b-256 | 48ad741d09850c0de43552e02817e73d7c59056e2f13c3e46b457ffda76dafc4 |
File details
Details for the file tonbo-0.1.0-cp310-abi3-win_amd64.whl
.
File metadata
- Download URL: tonbo-0.1.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82b37f9c0ebb93de3861d1d7859d424e449d5b86510fe8de495ad4faaa8a3d30 |
|
MD5 | db9716ecf80ef74553103b2549881394 |
|
BLAKE2b-256 | b285df10dbfa59905192220f789d437aa35387e87f1b6eff7fb7ca6f7dfece39 |
File details
Details for the file tonbo-0.1.0-cp310-abi3-win32.whl
.
File metadata
- Download URL: tonbo-0.1.0-cp310-abi3-win32.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.10+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63f0dfe82958405f0b293ad6cf37c3fa4a94b3fd092de6934d49d7a27cae3275 |
|
MD5 | 99f224b74305f69683d1f36ba090f0d7 |
|
BLAKE2b-256 | 16b236fdfaf3b6e225925c8f8b8df2432e7b888f6dfe05dcc6a119db624c71c8 |
File details
Details for the file tonbo-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: tonbo-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.7 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8b4159ca555d39d8d5e34dcf798e3b97b49d09a421c03b66593d339592fb039 |
|
MD5 | 215c2bedbb94e6f62bcd06d276e26896 |
|
BLAKE2b-256 | 74d425cefbec006bb4ad38615714bf7f98fb1c9ae0eba5fe5cb3ce199866b5a3 |
File details
Details for the file tonbo-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: tonbo-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 6.1 MB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c4f6be7969d298679ff53b364311cc205bf83a7bbe1a04995aa38aaae542ab2 |
|
MD5 | 8b4ea4b9403c9b1c331971da91a2a274 |
|
BLAKE2b-256 | 53799aae6f4931f7b554a9d2d60daeebe323f9a3afbbcd52e9495b919455fab9 |