Skip to main content

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())

Type Mapping

Databend Types

General Data Types

Databend Python
BOOLEAN bool
TINYINT int
SMALLINT int
INT int
BIGINT int
FLOAT float
DOUBLE float
DECIMAL decimal.Decimal
DATE datetime.date
TIMESTAMP datetime.datetime
VARCHAR str
BINARY bytes

Semi-Structured Data Types

Databend Python
ARRAY list
TUPLE tuple
MAP dict
VARIANT str
BITMAP str
GEOMETRY str

Note: VARIANT is a json encoded string. Example:

CREATE TABLE example (
    data VARIANT
);
INSERT INTO example VALUES ('{"a": 1, "b": "hello"}');
row = await conn.query_row("SELECT * FROM example limit 1;")
data = row.values()[0]
value = json.loads(data)
print(value)

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/*

Release files for databend-driver 0.17.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for databend-driver 0.17.3
File
databend_driver-0.17.3-cp37-abi3-win_amd64.whl CPython 3.7 abi3 Windows x86-64 Details
databend_driver-0.17.3-cp37-abi3-manylinux_2_28_aarch64.whl CPython 3.7 abi3 Linux glibc 2.28+ ARM64 Details
databend_driver-0.17.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 abi3 Linux glibc 2.17+ x86-64 Details
databend_driver-0.17.3-cp37-abi3-macosx_11_0_arm64.whl CPython 3.7 abi3 macOS 11.0+ ARM64 Details
databend_driver-0.17.3-cp37-abi3-macosx_10_12_x86_64.whl CPython 3.7 abi3 macOS 10.12+ x86-64 Details

Total release size:23.6 MB

Release files / databend_driver-0.17.3-cp37-abi3-win_amd64.whl

Download URL databend_driver-0.17.3-cp37-abi3-win_amd64.whl
Size 4.8 MB
Tags CPython 3.7 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
4a6feacb7d935f685db8884a68726cc666599ca92ee51d147d082a093367de96
BLAKE2b-256 checksum
How to use checksums
f7cc1a1c09f6c22c6d5e45de2ce3f5f8c759247eba87e8d8004e850c7b89e66d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / databend_driver-0.17.3-cp37-abi3-manylinux_2_28_aarch64.whl

Download URL databend_driver-0.17.3-cp37-abi3-manylinux_2_28_aarch64.whl
Size 4.6 MB
Tags CPython 3.7 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
aed455f68c4f045d84c34519e9e2f0c54461e41ecdfc776baac06a9618a7771c
BLAKE2b-256 checksum
How to use checksums
347401320e9da1fae97a7e60230d482af50533d48a804f37fa2f3eee4c659cca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / databend_driver-0.17.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL databend_driver-0.17.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.0 MB
Tags CPython 3.7 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
841f79f30692d776b4992bfeb7cf0c93609182f07ab0c6d7d4db3739bd55ca99
BLAKE2b-256 checksum
How to use checksums
66a29caf158a9945e6f2e8e5f9b7331ad2c6032c64dbac123bf43326d4627595
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / databend_driver-0.17.3-cp37-abi3-macosx_11_0_arm64.whl

Download URL databend_driver-0.17.3-cp37-abi3-macosx_11_0_arm64.whl
Size 4.5 MB
Tags CPython 3.7 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
23bf34b94225197bec38eb43c3f5aceea6bb98dde0d9a6c34fd75b7a820310be
BLAKE2b-256 checksum
How to use checksums
bcd988b55aca1045679e2aac4c299601481b1a98d2c4c07acaaca58ed2cf7d36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / databend_driver-0.17.3-cp37-abi3-macosx_10_12_x86_64.whl

Download URL databend_driver-0.17.3-cp37-abi3-macosx_10_12_x86_64.whl
Size 4.8 MB
Tags CPython 3.7 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
cfe060647e9e6ce71fa2e311f0f53bfb8df0ba5dc6aa8a6af00eb64f7c2a5b28
BLAKE2b-256 checksum
How to use checksums
07b466033c1f8d3eb44e931409751a9cfea2697595bc23e8a66b8bd36d31732a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.34.2

8 release files

0.34.0

8 release files

0.33.6

8 release files

0.33.5

8 release files

0.30.3

4 release files

0.30.2

4 release files

0.30.1

4 release files

0.29.1

4 release files

0.29.0

4 release files

0.28.2

4 release files

0.28.0

4 release files

0.27.5

5 release files

0.27.4

5 release files

0.27.3

5 release files

0.27.1

5 release files

0.27.0

5 release files

0.26.1

5 release files

0.26.0

5 release files

0.25.4

5 release files

0.25.2

5 release files

0.25.1

5 release files

0.24.7

5 release files

0.24.5

5 release files

0.24.4

5 release files

0.23.2

5 release files

0.23.1

5 release files

0.23.0

5 release files

0.22.2

5 release files

0.22.0

5 release files

0.21.1

5 release files

0.19.5

5 release files

0.19.4

5 release files

0.19.3

5 release files

0.19.2

5 release files

0.19.1

5 release files

0.19.0

5 release files

0.18.3

5 release files

0.18.2

5 release files

0.18.1

5 release files

0.18.0

5 release files

This release

0.17.3 This release

5 release files

0.17.1

5 release files

0.17.0

4 release files

0.16.3

4 release files

0.16.2

4 release files

0.16.0

4 release files

0.15.0

4 release files

0.14.0

4 release files

0.12.5

4 release files

0.12.4

4 release files

0.12.3

4 release files

0.12.1

4 release files

0.11.3

5 release files

0.11.2

5 release files

0.11.1

5 release files

0.11.0

5 release files

0.10.0

5 release files

0.9.5

5 release files

0.9.4

5 release files

0.9.3

5 release files

0.9.1

5 release files

0.9.0

5 release files

0.8.2

5 release files

0.8.1

5 release files

0.8.0

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page