tikv-client


Nametikv-client JSON
Version 0.0.4 PyPI version JSON
download
home_page
SummaryTiKV Client for Python
upload_time2024-01-17 02:04:43
maintainer
docs_urlNone
authorAndy Lok <andylokandy@hotmail.com>
requires_python>=3.6
license
keywords tikv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TiKV Client (Python)

![Publish](https://github.com/tikv/client-py/workflows/Publish/badge.svg)

This library is a TiKV client in Python; it supports both synchronous and asynchronous API.

It's built on top of
[TiKV Client in Rust](https://github.com/tikv/client-rust) via
CFFI and [PyO3 Python binding](https://github.com/PyO3/pyo3).

This client is still in the stage of prove-of-concept and under heavy development.

## Install

This package requires Python 3.6+ and pip 19+. Currently only supports MacOS (x86_64 and aarch64) and Linux in x86_64 with GLibc >= 2.12.

```
pip3 install tikv-client
```

## Install (Development)

```
> pip3 install maturin

> maturin build
🍹 Building a mixed python/rust project
🔗 Found pyo3 bindings
🐍 Found CPython 3.8 at python3.8
📦 Built source distribution to /home/andy/Code/client-py/target/wheels/tikv_client-0.1.0.tar.gz
    Blocking waiting for file lock on build directory
   Compiling pyo3 v0.12.3
   Compiling tikv-client v0.1.0 (/home/andy/Code/client-py)
    Finished dev [unoptimized + debuginfo] target(s) in 17.62s
📦 Built wheel for CPython 3.8 to /home/andy/Code/client-py/target/wheels/tikv_client-0.1.0-cp38-cp38-manylinux1_x86_64.whl

> pip3 install target/wheels/tikv_client-0.1.0-cp38-cp38-manylinux1_x86_64.whl
Installing collected packages: tikv-client
Successfully installed tikv-client-0.1.0
```

## Example

Python TiKV client is synchronous by defult:

```python
from tikv_client import TransactionClient

client = TransactionClient.connect("127.0.0.1:2379")

txn = client.begin(pessimistic=True)
txn.put(b"k1", b"v1")
txn.put(b"k2", b"v2")
txn.put(b"k3", b"v3")
txn.put(b"k4", b"v4")
txn.put(b"k5", b"v5")
txn.commit()

snapshot = client.snapshot(client.current_timestamp())
print(snapshot.get(b"k3"))
print(snapshot.batch_get([b"k1", b"k4"]))

for k, v in snapshot.scan(b"k1", end=None, limit=10, include_start=False):
    print(k, v)
```

Asynchronous client is available in `tikv_client.asynchronous` module. Modules and classes under this modules is similar to the synchronous ones.

```python
import asyncio
from tikv_client.asynchronous import TransactionClient

async def main():
    client = await TransactionClient.connect("127.0.0.1:2379")

    txn = await client.begin(pessimistic=True)
    await txn.put(b"k1", b"v1")
    await txn.put(b"k2", b"v2")
    await txn.put(b"k3", b"v3")
    await txn.put(b"k4", b"v4")
    await txn.put(b"k5", b"v5")
    await txn.commit()

    snapshot = client.snapshot(await client.current_timestamp())
    print(await snapshot.get(b"k3"))
    print(await snapshot.batch_get([b"k1", b"k4"]))

    for k, v in await snapshot.scan(b"k1", end=None, limit=10, include_start=False):
        print(k, v)

event_loop = asyncio.get_event_loop()
asyncio.get_event_loop().run_until_complete(main())
```


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "tikv-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "Andy Lok <andylokandy@hotmail.com>",
    "keywords": "TiKV",
    "author": "Andy Lok <andylokandy@hotmail.com>",
    "author_email": "Andy Lok <andylokandy@hotmail.com>",
    "download_url": "",
    "platform": null,
    "description": "# TiKV Client (Python)\n\n![Publish](https://github.com/tikv/client-py/workflows/Publish/badge.svg)\n\nThis library is a TiKV client in Python; it supports both synchronous and asynchronous API.\n\nIt's built on top of\n[TiKV Client in Rust](https://github.com/tikv/client-rust) via\nCFFI and [PyO3 Python binding](https://github.com/PyO3/pyo3).\n\nThis client is still in the stage of prove-of-concept and under heavy development.\n\n## Install\n\nThis package requires Python 3.6+ and pip 19+. Currently only supports MacOS (x86_64 and aarch64) and Linux in x86_64 with GLibc >= 2.12.\n\n```\npip3 install tikv-client\n```\n\n## Install (Development)\n\n```\n> pip3 install maturin\n\n> maturin build\n\ud83c\udf79 Building a mixed python/rust project\n\ud83d\udd17 Found pyo3 bindings\n\ud83d\udc0d Found CPython 3.8 at python3.8\n\ud83d\udce6 Built source distribution to /home/andy/Code/client-py/target/wheels/tikv_client-0.1.0.tar.gz\n    Blocking waiting for file lock on build directory\n   Compiling pyo3 v0.12.3\n   Compiling tikv-client v0.1.0 (/home/andy/Code/client-py)\n    Finished dev [unoptimized + debuginfo] target(s) in 17.62s\n\ud83d\udce6 Built wheel for CPython 3.8 to /home/andy/Code/client-py/target/wheels/tikv_client-0.1.0-cp38-cp38-manylinux1_x86_64.whl\n\n> pip3 install target/wheels/tikv_client-0.1.0-cp38-cp38-manylinux1_x86_64.whl\nInstalling collected packages: tikv-client\nSuccessfully installed tikv-client-0.1.0\n```\n\n## Example\n\nPython TiKV client is synchronous by defult:\n\n```python\nfrom tikv_client import TransactionClient\n\nclient = TransactionClient.connect(\"127.0.0.1:2379\")\n\ntxn = client.begin(pessimistic=True)\ntxn.put(b\"k1\", b\"v1\")\ntxn.put(b\"k2\", b\"v2\")\ntxn.put(b\"k3\", b\"v3\")\ntxn.put(b\"k4\", b\"v4\")\ntxn.put(b\"k5\", b\"v5\")\ntxn.commit()\n\nsnapshot = client.snapshot(client.current_timestamp())\nprint(snapshot.get(b\"k3\"))\nprint(snapshot.batch_get([b\"k1\", b\"k4\"]))\n\nfor k, v in snapshot.scan(b\"k1\", end=None, limit=10, include_start=False):\n    print(k, v)\n```\n\nAsynchronous client is available in `tikv_client.asynchronous` module. Modules and classes under this modules is similar to the synchronous ones.\n\n```python\nimport asyncio\nfrom tikv_client.asynchronous import TransactionClient\n\nasync def main():\n    client = await TransactionClient.connect(\"127.0.0.1:2379\")\n\n    txn = await client.begin(pessimistic=True)\n    await txn.put(b\"k1\", b\"v1\")\n    await txn.put(b\"k2\", b\"v2\")\n    await txn.put(b\"k3\", b\"v3\")\n    await txn.put(b\"k4\", b\"v4\")\n    await txn.put(b\"k5\", b\"v5\")\n    await txn.commit()\n\n    snapshot = client.snapshot(await client.current_timestamp())\n    print(await snapshot.get(b\"k3\"))\n    print(await snapshot.batch_get([b\"k1\", b\"k4\"]))\n\n    for k, v in await snapshot.scan(b\"k1\", end=None, limit=10, include_start=False):\n        print(k, v)\n\nevent_loop = asyncio.get_event_loop()\nasyncio.get_event_loop().run_until_complete(main())\n```\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "TiKV Client for Python",
    "version": "0.0.4",
    "project_urls": null,
    "split_keywords": [
        "tikv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c51f8bf39a2c5ee1227090015a68f3b118deaecf2d9a8ffab8b192339dc17de",
                "md5": "de51004e12433378b2a47d5d6ea41166",
                "sha256": "ec3b19b43af3a6d7360f67a58dd43cf1dffd86f3c2109ece7c7b3a50f9711188"
            },
            "downloads": -1,
            "filename": "tikv_client-0.0.4-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl",
            "has_sig": false,
            "md5_digest": "de51004e12433378b2a47d5d6ea41166",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.6",
            "size": 9053999,
            "upload_time": "2024-01-17T02:04:43",
            "upload_time_iso_8601": "2024-01-17T02:04:43.846397Z",
            "url": "https://files.pythonhosted.org/packages/6c/51/f8bf39a2c5ee1227090015a68f3b118deaecf2d9a8ffab8b192339dc17de/tikv_client-0.0.4-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ee18a67b50bd2ae4e1e714a17535f90f993e56b4d1e3c9afc5449ce8437554f",
                "md5": "e8b6ee043a0757ac23e9cbbb63c509e6",
                "sha256": "a1d19c98a4473eabc2357136af3a42089b8bfd73ec350599fe4cc329e7f1e875"
            },
            "downloads": -1,
            "filename": "tikv_client-0.0.4-cp311-cp311-macosx_10_12_x86_64.whl",
            "has_sig": false,
            "md5_digest": "e8b6ee043a0757ac23e9cbbb63c509e6",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.6",
            "size": 4595638,
            "upload_time": "2024-01-17T02:04:47",
            "upload_time_iso_8601": "2024-01-17T02:04:47.108951Z",
            "url": "https://files.pythonhosted.org/packages/2e/e1/8a67b50bd2ae4e1e714a17535f90f993e56b4d1e3c9afc5449ce8437554f/tikv_client-0.0.4-cp311-cp311-macosx_10_12_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25d956e3cb553417aa09b54ab1aa1c034e40f3609f6d741c42750b486dc6f56c",
                "md5": "d1082da9f008f748ac3a0c3f725eeb0c",
                "sha256": "e3ff1c4dbd7188fbc8609b5106194042583b164614db344a7ae6204527423341"
            },
            "downloads": -1,
            "filename": "tikv_client-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "d1082da9f008f748ac3a0c3f725eeb0c",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.6",
            "size": 6701394,
            "upload_time": "2024-01-17T02:04:50",
            "upload_time_iso_8601": "2024-01-17T02:04:50.069450Z",
            "url": "https://files.pythonhosted.org/packages/25/d9/56e3cb553417aa09b54ab1aa1c034e40f3609f6d741c42750b486dc6f56c/tikv_client-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0423119f6e69557c3b6f3126d83ff7b802b4931d39e053b9b19d2a42f403f827",
                "md5": "0a7cc99cf4fc5c6e075bbb840a1c0070",
                "sha256": "5922f5b829dab29b00882788a85ee7e26e6f5ae802decc5df62dd67ac8717529"
            },
            "downloads": -1,
            "filename": "tikv_client-0.0.4-cp311-none-win32.whl",
            "has_sig": false,
            "md5_digest": "0a7cc99cf4fc5c6e075bbb840a1c0070",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.6",
            "size": 3579741,
            "upload_time": "2024-01-17T02:04:51",
            "upload_time_iso_8601": "2024-01-17T02:04:51.862534Z",
            "url": "https://files.pythonhosted.org/packages/04/23/119f6e69557c3b6f3126d83ff7b802b4931d39e053b9b19d2a42f403f827/tikv_client-0.0.4-cp311-none-win32.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf0cd197c0c2671e65f62b2b1f2c03292991c782a7fa19b5f5240fcb3c3617b5",
                "md5": "e9e2fc5f1dcbaefb5b651db355e8ad9d",
                "sha256": "1f29539db0d850bf91672163814a9742bdb78c48325205ba2c3eedf1f7c646b6"
            },
            "downloads": -1,
            "filename": "tikv_client-0.0.4-cp311-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "e9e2fc5f1dcbaefb5b651db355e8ad9d",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.6",
            "size": 4303600,
            "upload_time": "2024-01-17T02:04:54",
            "upload_time_iso_8601": "2024-01-17T02:04:54.336823Z",
            "url": "https://files.pythonhosted.org/packages/bf/0c/d197c0c2671e65f62b2b1f2c03292991c782a7fa19b5f5240fcb3c3617b5/tikv_client-0.0.4-cp311-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-17 02:04:43",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "tikv-client"
}
        
Elapsed time: 0.31063s