Skip to main content

Databend Driver Python Binding

Project description

databend-driver

Build

cd bindings/python
maturin develop

Usage

Blocking

from databend_driver import BlockingDatabendClient

client = BlockingDatabendClient('databend+http://root:root@localhost:8000/?sslmode=disable')
conn = client.get_conn()
conn.exec(
    """
    CREATE TABLE test (
        i64 Int64,
        u64 UInt64,
        f64 Float64,
        s   String,
        s2  String,
        d   Date,
        t   DateTime
    )
    """
)
rows = conn.query_iter("SELECT * FROM test")
for row in rows:
    print(row.values())

Asyncio

import asyncio
from databend_driver import AsyncDatabendClient

async def main():
    client = AsyncDatabendClient('databend+http://root:root@localhost:8000/?sslmode=disable')
    conn = await client.get_conn()
    await conn.exec(
        """
        CREATE TABLE test (
            i64 Int64,
            u64 UInt64,
            f64 Float64,
            s   String,
            s2  String,
            d   Date,
            t   DateTime
        )
        """
    )
    rows = await conn.query_iter("SELECT * FROM test")
    async for row in rows:
        print(row.values())

asyncio.run(main())

APIs

AsyncDatabendClient

class AsyncDatabendClient:
    def __init__(self, dsn: str): ...
    async def get_conn(self) -> AsyncDatabendConnection: ...

AsyncDatabendConnection

class AsyncDatabendConnection:
    async def info(self) -> ConnectionInfo: ...
    async def version(self) -> str: ...
    async def exec(self, sql: str) -> int: ...
    async def query_row(self, sql: str) -> Row: ...
    async def query_iter(self, sql: str) -> RowIterator: ...
    async def stream_load(self, sql: str, data: list[list[str]]) -> ServerStats: ...

BlockingDatabendClient

class BlockingDatabendClient:
    def __init__(self, dsn: str): ...
    def get_conn(self) -> BlockingDatabendConnection: ...

BlockingDatabendConnection

class BlockingDatabendConnection:
    def info(self) -> ConnectionInfo: ...
    def version(self) -> str: ...
    def exec(self, sql: str) -> int: ...
    def query_row(self, sql: str) -> Row: ...
    def query_iter(self, sql: str) -> RowIterator: ...
    def stream_load(self, sql: str, data: list[list[str]]) -> ServerStats: ...

Row

class Row:
    def values(self) -> tuple: ...

RowIterator

class RowIterator:
    def schema(self) -> Schema: ...

    def __iter__(self) -> RowIterator: ...
    def __next__(self) -> Row: ...

    def __aiter__(self) -> RowIterator: ...
    async def __anext__(self) -> Row: ...

Field

class Field:
    @property
    def name(self) -> str: ...
    @property
    def data_type(self) -> str: ...

Schema

class Schema:
    def fields(self) -> list[Field]: ...

ServerStats

class ServerStats:
    @property
    def total_rows(self) -> int: ...
    @property
    def total_bytes(self) -> int: ...
    @property
    def read_rows(self) -> int: ...
    @property
    def read_bytes(self) -> int: ...
    @property
    def write_rows(self) -> int: ...
    @property
    def write_bytes(self) -> int: ...
    @property
    def running_time_ms(self) -> float: ...

ConnectionInfo

class ConnectionInfo:
    @property
    def handler(self) -> str: ...
    @property
    def host(self) -> str: ...
    @property
    def port(self) -> int: ...
    @property
    def user(self) -> str: ...
    @property
    def database(self) -> str | None: ...
    @property
    def warehouse(self) -> str | None: ...

Development

cd tests
make up
cd bindings/python
pipenv install --dev
pipenv run maturin develop
pipenv run behave tests/*

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

databend_driver-0.12.0-cp37-abi3-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.7+Windows x86-64

databend_driver-0.12.0-cp37-abi3-manylinux_2_31_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.31+ x86-64

databend_driver-0.12.0-cp37-abi3-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

databend_driver-0.12.0-cp37-abi3-macosx_10_12_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file databend_driver-0.12.0-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for databend_driver-0.12.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 08adbff684de39e8b005dbd459d81154ad9f53ccf29df66785d96dd1c08682b9
MD5 f6a49d26e2d989a7ad11057525c1927b
BLAKE2b-256 e485417ac1f36e1d0606d403a03aad685f07eb4be9349945f37d2fde8a209e2e

See more details on using hashes here.

File details

Details for the file databend_driver-0.12.0-cp37-abi3-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for databend_driver-0.12.0-cp37-abi3-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 a61c2b81f3aa34183e6bc0547053d28620af8cfbafa1c80b2aef243b9c318f89
MD5 3e5861074df541ce931176d66588f6ca
BLAKE2b-256 8b7a197697f7a56988f35bb8907bd23cfba6052fc74a88e05cb68f10cfe35f70

See more details on using hashes here.

File details

Details for the file databend_driver-0.12.0-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for databend_driver-0.12.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fbd4a9cea30db80c408b792abc753a88999c16fa9f7df9795ce89a2bcdaec3d4
MD5 8e7db1055e1c54c2798f179c42423e5d
BLAKE2b-256 fc908dace6b06366e0ffe4940ae1ab200cab4c83e8e25731a35cfe04279c4f44

See more details on using hashes here.

File details

Details for the file databend_driver-0.12.0-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for databend_driver-0.12.0-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 64a9d4aa0302382769f5831346058c0d23070af1aeb30e1005cf69af8384a55f
MD5 ad50d6767f556e019e81d88bbdbb6134
BLAKE2b-256 a95cae5f2e705b0571168a40d323d3080a5c75bc93f55c782f10bfdc1d43909d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page