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


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

databend_driver-0.16.1-cp37-abi3-win_amd64.whl (4.7 MB view details)

Uploaded CPython 3.7+Windows x86-64

databend_driver-0.16.1-cp37-abi3-manylinux_2_31_x86_64.whl (4.9 MB view details)

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

databend_driver-0.16.1-cp37-abi3-macosx_11_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

databend_driver-0.16.1-cp37-abi3-macosx_10_12_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for databend_driver-0.16.1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d736846b90800ce7369dc382a73f594b002b884163bf023888fa5ae7bf653b27
MD5 3fbcca5a0c9f0b52817d01bbbb74b80b
BLAKE2b-256 3fc8ed96d4f4ac0a6ba573f60bf8f786f6292e42cfcba1d03d0e0db46e9ade7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for databend_driver-0.16.1-cp37-abi3-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 394a9f59a272bf6d7944ae1ff3ae763f5fa3c25077a55817a9b671e0390703f9
MD5 1d1b382df5362285a9f2ab84f03dad9f
BLAKE2b-256 e350267bc0c6bb6c7427984fe53f1f8bed4cd69d90187e070c7399df19d8b657

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for databend_driver-0.16.1-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99b46faf9aa6c845e46b7ee834adfa07915c57d83a4a143c9e3c5754baeac264
MD5 fa70fa5f3305344bbddbc4cfd0ec5e24
BLAKE2b-256 6a4fd61674dbdb1178680d0fca4291704199c4b19883e1984892396f4d9e611a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for databend_driver-0.16.1-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 29ee4f398e243162abd4210a078279007ec5ce3eff6eda5b789c96e44f5af61d
MD5 dfb5bceed3080bb4df286143698cbe92
BLAKE2b-256 0b50e22b9fcf68e359e2be7554e49d90cad721907ad63a416ea6b67dd67e5672

See more details on using hashes here.

Supported by

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