bytehouse-driver


Namebytehouse-driver JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://github.com/bytehouse-cloud/driver-py
SummaryPython driver with native interface for ByteHouse
upload_time2024-04-17 10:48:45
maintainerNone
docs_urlNone
authorSayan Dutta Chowdhury
requires_python<4,>=3.6
licenseMIT
keywords bytehouse db database cloud analytics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # ByteHouse Python Driver
## Introduction 
ByteHouse provides a Python driver that supports Python Database API Specification v2.0. The driver can be used with 
most client tools/applications/BI tools which accept python driver following python DB API 2.0. The driver uses 
TCP/Native protocol to connect to ByteHouse.

## Requirements
Python v3.6 or higher

## Installation from PyPI
Latest release version can be installed from here:
```commandline
pip install bytehouse-driver
```
## Installation from github
Current development version can be installed from here:
```commandline
pip install git+https://github.com/bytehouse-cloud/driver-py@master#egg=bytehouse-driver
```
## Creating ByteHouse Account
You need to create ByteHouse account in order to use Python Driver. You can simply create a free account with the 
process mentioned in our official website documentation: https://docs.bytehouse.cloud/en/docs/quick-start<br/>

You can also create ByteHouse account through Volcano Engine by ByteDance: 
https://www.volcengine.com/product/bytehouse-cloud

## ByteHouse Regions
Currently, the driver supports the following region names across different cloud providers. Alternatively, if you know
the host address of ByteHouse server, you can directly use host address & omit region name. 
<table>
    <tr>
        <td>Region Name</td>
        <td>Target Server</td>
    </tr>
    <tr>
        <td>AP-SOUTHEAST-1</td>
        <td>gateway.aws-ap-southeast-1.bytehouse.cloud:19000</td>
    </tr>
    <tr>
        <td>VOLCANO-CN-NORTH-1</td>
        <td>bytehouse-cn-beijing.volces.com:19000</td>
    </tr>
</table>

## URI format for Connection & Authentication
### Region & Password Format
*Required parameters:* `region` `account` `user` `password`
```python
'bytehouse:///?region={}&account={}&user={}&password={}'.format(REGION, ACCOUNT, USER, PASSWORD)
```
### Host Address & Password Format
*Required parameters:* `host` `port` `account` `user` `password`
```python
'bytehouse://{}:{}/?account={}&user={}&password={}'.format(HOST, PORT, ACCOUNT, USER, PASSWORD)
```
> For API Key authentication, user is always 'bytehouse'
### Region & API Key Format
*Required parameters:* `region` `password`
```python
'bytehouse:///?region={}&user=bytehouse&password={}'.format(REGION, API_KEY)
```
### Host Address & API Key Format
*Required parameters:* `host` `port` `password`
```python
'bytehouse://{}:{}/?user=bytehouse&password={}'.format(HOST, PORT, API_KEY)
```
## Virtual warehouse & Role Management
Connection initialiaztion with ByteHouse always assumes default virtual warehouse & active role, therefore these values
cannot be empty. So before using the driver, users need to set/ensure these values through 
https://console.bytehouse.cloud/account/details
![Default Settings](./default_settings.png)
## Constructing Client Object
### Passing parameters
```python
from bytehouse_driver import Client

client = Client(
    region=REGION,
    account=ACCOUNT,
    user=USER,
    password=PASSWORD
)
```
### From URI
```python
from bytehouse_driver import Client

client = Client.from_url('bytehouse:///?region={}&account={}&user={}&password{}'.format(
     REGION, ACCOUNT, USER, PASSWORD)
)
```
## Performing SQL queries
```python
from bytehouse_driver import Client

client = Client(
    region=REGION,
    account=ACCOUNT,
    user=USER,
    password=PASSWORD
)
# DDL Query
client.execute("CREATE DATABASE demo_db")
client.execute("CREATE TABLE demo_db.demo_tb (id INT) ENGINE=CnchMergeTree() ORDER BY tuple()")

# DML Query
client.execute("INSERT INTO demo_db.demo_tb VALUES", [[1], [2], [3]])

# DQL Query
result_set = client.execute("SELECT * FROM demo_db.demo_tb")
for result in result_set:
    print(result)

client.execute("DROP DATABASE demo_db")
```
## Supported Datatypes
| **ByteHouse type**                                                       | **Python type for INSERT**               | **Python type for SELECT**  |
|----------------------------------------------------------------------|--------------------------------------|-------------------------|
| Integar family (UInt8/UInt16/UInt32/UInt64 / Int8/Int16/Int32/Int64) | `int` `long`                             | `int`                     |
| Float family (Float32/Float64)                                       | `float` `int` `long`                       | `float`                   |
| String                                                               | `str` `bytes`                            | `str` `bytes`               |
| FixedString                                                          | `str` `bytes`                            | `str` `bytes`               |
| Nullable<T>                                                          | `None` `T`                               | `None` `T`                  |
| Date                                                                 | `date` `datetime`                        | `date`                    |
| DateTime                                                             | `datetime` `int` `long`                    | `datetime`                |
| Array                                                                | `list` `tuple`                           | `list`                    |
| Enum family                                                          | `Enum` `int` `long` `str`                    | `str`                     |
| Decimal                                                              | `Decimal` `float` `int` `long`               | `Decimal`                 |
| IP family                                                            | `IPv4Address` `IPv6Address` `int` `long` `str` | `IPv4Address` `IPv6Address` |
| Map                                                                  | `dict`                                 | `dict`                    |
| LowCardinality<T>                                                    | `T`                                    | `T`                       |
| UUID                                                                 | `UUID` `str`                             | `UUID`                    |
### Settings types_check=True
Default value for 'types_check' is false for performance. If set to true, then explicit type checking and transformation
would happen before passing the data onto the server. Recommended to set it to true, for float/decimal or any other 
types, where raw data needs to be transformed into appropriate type. 
### Integer family
`Int8` `Int16` `Int32` `Int64` `UInt8` `UInt16` `UInt32` `UInt64`
```python
client.execute("CREATE TABLE demo_db.demo_tb (a Int8, b Int16, c Int32, d Int64, e UInt8, f UInt16, g UInt32, h UInt64) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [
    (-10, -300, -123581321, -123581321345589144, 10, 300, 123581321, 123581321345589144)
]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### Float family
`Float32` `Float64`
```python
client.execute("CREATE TABLE demo_db.demo_tb (a Float32, b Float64) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [
    (3.4028235e38, 3.4028235e38),
    (3.4028235e39, 3.4028235e39),
    (-3.4028235e39, 3.4028235e39),
    (1, 2)
]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data, types_check=True)
```
### String
```python
client.execute("CREATE TABLE demo_db.demo_tb (a String) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [('axdfgrt', )]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### FixedString
```python
client.execute("CREATE TABLE demo_db.demo_tb (a FixedString(4)) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [('a', ), ('bb', ), ('ccc', ), ('dddd', ), ('я', )]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### Nullable
```python
client.execute("CREATE TABLE demo_db.demo_tb (a Nullable(Int32)) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [(3, ), (None, ), (2, )]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### Date
```python
from datetime import date, datetime

client.execute("CREATE TABLE demo_db.demo_tb (a Date) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [(date(1970, 1, 1), ), (datetime(2015, 6, 6, 12, 30, 54), )]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### DateTime
```python
from datetime import datetime

client.execute("CREATE TABLE demo_db.demo_tb (a DateTime) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [(datetime(2015, 6, 6, 12, 30, 54), ), (1530211034,)]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### Array
```python
client.execute("CREATE TABLE demo_db.demo_tb (a Array(Int32)) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [([], ), ([100, 500], )]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### Enum family
`Enum8` `Enum16`
```python
from enum import IntEnum

class A(IntEnum):
    hello = -1
    world = 2

class B(IntEnum):
    foo = -300
    bar = 300

client.execute("CREATE TABLE demo_db.demo_tb (a Enum8('hello' = -1, 'world' = 2), b Enum16('foo' = -300, 'bar' = 300)) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [(A.hello, B.bar), (A.world, B.foo), (-1, 300), (2, -300)]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### Decimal
```python
from decimal import Decimal

client.execute("CREATE TABLE demo_db.demo_tb (a Decimal(9, 5)) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [(Decimal('300.42'),), (300.42,), (-300,)]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data, types_check=True)
```
### IP family
`IPv4` `IPv6`
```python
from ipaddress import IPv6Address, IPv4Address

client.execute("CREATE TABLE demo_db.demo_tb (a IPv4, b IPv6) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [
    (IPv4Address("10.0.0.1"), IPv6Address('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'),),
]
client.execute("INSERT INTO demo_db.demo_tb (a, b) VALUES", data)
```
### Map
```python
client.execute("CREATE TABLE demo_db.demo_tb (a Map(String, UInt64)) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [
    ({},),
    ({'key1': 1},),
    ({'key1': 2, 'key2': 20},),
    ({'key1': 3, 'key2': 30, 'key3': 50},)
]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### LowCardinality
```python
client.execute("CREATE TABLE demo_db.demo_tb (a LowCardinality(UInt8)) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [(x,) for x in range(255)]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
### UUID
```python
from uuid import UUID

client.execute("CREATE TABLE demo_db.demo_tb (a UUID) ENGINE=CnchMergeTree() ORDER BY tuple()")
data = [
    (UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'),),
    ('2efcead4-ff55-4db5-bdb4-6b36a308d8e0',)
]
client.execute("INSERT INTO demo_db.demo_tb VALUES", data)
```
## Cursor Support: DB API 2.0
Cursors are supported following DB API 2.0 specifications. Cursors are created by the connection.cursor() method. They 
are bound to the connection for the entire lifetime and all the commands are executed in the context of the database 
session wrapped by the connection.
```python
from bytehouse_driver import connect

kwargs = {}
kwargs.setdefault('region', REGION)
kwargs.setdefault('account', ACCOUNT)
kwargs.setdefault('user', USER)
kwargs.setdefault('password', PASSWORD)

connection = connect(**kwargs)
cursor = connection.cursor()

cursor.execute("DROP TABLE IF EXISTS cursor_tb")
cursor.execute("CREATE TABLE cursor_tb (id INT) ENGINE=CnchMergeTree() ORDER BY tuple()")

cursor.executemany("INSERT INTO cursor_tb (id) VALUES", [{'id': 100}])

result_set = cursor.execute("SELECT * FROM cursor_tb")
for result in result_set:
    print(result)

connection.close()
```
## User defined query-id
User can manually supply query-id for each query execution. Users are encouraged to maintain uniqueness or relevancy 
of the query-id string. If not set, then server will assign a randomly generated UUID as the query-id. 
```python
client = Client(
    region=self.region,
    account=self.account,
    user=self.user,
    password=self.password
)
client.execute("SELECT 1", query_id="ba2e2cea-2a11-4926-a0b8-e694ded0cf65")
```
## Local Development
Change `setup.cfg` file to include your connection credentials. For running tests locally, follow these steps:
```python
python testsrequire.py && python setup.py develop
py.test -v
```
## Issue Reporting
If you have found a bug or if you have a feature request, please report them at this repository issues section. 
Alternatively, you can directly create an issue with our support platform here: https://bytehouse.cloud/support
## Original Author
ByteHouse wants to thank original author @Konstantin Lebedev & ClickHouse for original contribution to this driver. 
## License
This project is distributed under the terms of the MIT license: http://www.opensource.org/licenses/mit-license.php


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/bytehouse-cloud/driver-py",
    "name": "bytehouse-driver",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.6",
    "maintainer_email": null,
    "keywords": "ByteHouse db database cloud analytics",
    "author": "Sayan Dutta Chowdhury",
    "author_email": "sayan.chowdhury@bytedance.com",
    "download_url": "https://files.pythonhosted.org/packages/c5/bc/f5f090ed1a088ac8f6fbaa4066282230c6239ee181328bb421d34cfbc2de/bytehouse_driver-1.0.4.tar.gz",
    "platform": null,
    "description": "# ByteHouse Python Driver\n## Introduction \nByteHouse provides a Python driver that supports Python Database API Specification v2.0. The driver can be used with \nmost client tools/applications/BI tools which accept python driver following python DB API 2.0. The driver uses \nTCP/Native protocol to connect to ByteHouse.\n\n## Requirements\nPython v3.6 or higher\n\n## Installation from PyPI\nLatest release version can be installed from here:\n```commandline\npip install bytehouse-driver\n```\n## Installation from github\nCurrent development version can be installed from here:\n```commandline\npip install git+https://github.com/bytehouse-cloud/driver-py@master#egg=bytehouse-driver\n```\n## Creating ByteHouse Account\nYou need to create ByteHouse account in order to use Python Driver. You can simply create a free account with the \nprocess mentioned in our official website documentation: https://docs.bytehouse.cloud/en/docs/quick-start<br/>\n\nYou can also create ByteHouse account through Volcano Engine by ByteDance: \nhttps://www.volcengine.com/product/bytehouse-cloud\n\n## ByteHouse Regions\nCurrently, the driver supports the following region names across different cloud providers. Alternatively, if you know\nthe host address of ByteHouse server, you can directly use host address & omit region name. \n<table>\n    <tr>\n        <td>Region Name</td>\n        <td>Target Server</td>\n    </tr>\n    <tr>\n        <td>AP-SOUTHEAST-1</td>\n        <td>gateway.aws-ap-southeast-1.bytehouse.cloud:19000</td>\n    </tr>\n    <tr>\n        <td>VOLCANO-CN-NORTH-1</td>\n        <td>bytehouse-cn-beijing.volces.com:19000</td>\n    </tr>\n</table>\n\n## URI format for Connection & Authentication\n### Region & Password Format\n*Required parameters:* `region` `account` `user` `password`\n```python\n'bytehouse:///?region={}&account={}&user={}&password={}'.format(REGION, ACCOUNT, USER, PASSWORD)\n```\n### Host Address & Password Format\n*Required parameters:* `host` `port` `account` `user` `password`\n```python\n'bytehouse://{}:{}/?account={}&user={}&password={}'.format(HOST, PORT, ACCOUNT, USER, PASSWORD)\n```\n> For API Key authentication, user is always 'bytehouse'\n### Region & API Key Format\n*Required parameters:* `region` `password`\n```python\n'bytehouse:///?region={}&user=bytehouse&password={}'.format(REGION, API_KEY)\n```\n### Host Address & API Key Format\n*Required parameters:* `host` `port` `password`\n```python\n'bytehouse://{}:{}/?user=bytehouse&password={}'.format(HOST, PORT, API_KEY)\n```\n## Virtual warehouse & Role Management\nConnection initialiaztion with ByteHouse always assumes default virtual warehouse & active role, therefore these values\ncannot be empty. So before using the driver, users need to set/ensure these values through \nhttps://console.bytehouse.cloud/account/details\n![Default Settings](./default_settings.png)\n## Constructing Client Object\n### Passing parameters\n```python\nfrom bytehouse_driver import Client\n\nclient = Client(\n    region=REGION,\n    account=ACCOUNT,\n    user=USER,\n    password=PASSWORD\n)\n```\n### From URI\n```python\nfrom bytehouse_driver import Client\n\nclient = Client.from_url('bytehouse:///?region={}&account={}&user={}&password{}'.format(\n     REGION, ACCOUNT, USER, PASSWORD)\n)\n```\n## Performing SQL queries\n```python\nfrom bytehouse_driver import Client\n\nclient = Client(\n    region=REGION,\n    account=ACCOUNT,\n    user=USER,\n    password=PASSWORD\n)\n# DDL Query\nclient.execute(\"CREATE DATABASE demo_db\")\nclient.execute(\"CREATE TABLE demo_db.demo_tb (id INT) ENGINE=CnchMergeTree() ORDER BY tuple()\")\n\n# DML Query\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", [[1], [2], [3]])\n\n# DQL Query\nresult_set = client.execute(\"SELECT * FROM demo_db.demo_tb\")\nfor result in result_set:\n    print(result)\n\nclient.execute(\"DROP DATABASE demo_db\")\n```\n## Supported Datatypes\n| **ByteHouse type**                                                       | **Python type for INSERT**               | **Python type for SELECT**  |\n|----------------------------------------------------------------------|--------------------------------------|-------------------------|\n| Integar family (UInt8/UInt16/UInt32/UInt64 / Int8/Int16/Int32/Int64) | `int` `long`                             | `int`                     |\n| Float family (Float32/Float64)                                       | `float` `int` `long`                       | `float`                   |\n| String                                                               | `str` `bytes`                            | `str` `bytes`               |\n| FixedString                                                          | `str` `bytes`                            | `str` `bytes`               |\n| Nullable<T>                                                          | `None` `T`                               | `None` `T`                  |\n| Date                                                                 | `date` `datetime`                        | `date`                    |\n| DateTime                                                             | `datetime` `int` `long`                    | `datetime`                |\n| Array                                                                | `list` `tuple`                           | `list`                    |\n| Enum family                                                          | `Enum` `int` `long` `str`                    | `str`                     |\n| Decimal                                                              | `Decimal` `float` `int` `long`               | `Decimal`                 |\n| IP family                                                            | `IPv4Address` `IPv6Address` `int` `long` `str` | `IPv4Address` `IPv6Address` |\n| Map                                                                  | `dict`                                 | `dict`                    |\n| LowCardinality<T>                                                    | `T`                                    | `T`                       |\n| UUID                                                                 | `UUID` `str`                             | `UUID`                    |\n### Settings types_check=True\nDefault value for 'types_check' is false for performance. If set to true, then explicit type checking and transformation\nwould happen before passing the data onto the server. Recommended to set it to true, for float/decimal or any other \ntypes, where raw data needs to be transformed into appropriate type. \n### Integer family\n`Int8` `Int16` `Int32` `Int64` `UInt8` `UInt16` `UInt32` `UInt64`\n```python\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a Int8, b Int16, c Int32, d Int64, e UInt8, f UInt16, g UInt32, h UInt64) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [\n    (-10, -300, -123581321, -123581321345589144, 10, 300, 123581321, 123581321345589144)\n]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### Float family\n`Float32` `Float64`\n```python\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a Float32, b Float64) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [\n    (3.4028235e38, 3.4028235e38),\n    (3.4028235e39, 3.4028235e39),\n    (-3.4028235e39, 3.4028235e39),\n    (1, 2)\n]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data, types_check=True)\n```\n### String\n```python\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a String) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [('axdfgrt', )]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### FixedString\n```python\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a FixedString(4)) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [('a', ), ('bb', ), ('ccc', ), ('dddd', ), ('\u044f', )]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### Nullable\n```python\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a Nullable(Int32)) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [(3, ), (None, ), (2, )]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### Date\n```python\nfrom datetime import date, datetime\n\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a Date) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [(date(1970, 1, 1), ), (datetime(2015, 6, 6, 12, 30, 54), )]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### DateTime\n```python\nfrom datetime import datetime\n\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a DateTime) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [(datetime(2015, 6, 6, 12, 30, 54), ), (1530211034,)]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### Array\n```python\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a Array(Int32)) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [([], ), ([100, 500], )]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### Enum family\n`Enum8` `Enum16`\n```python\nfrom enum import IntEnum\n\nclass A(IntEnum):\n    hello = -1\n    world = 2\n\nclass B(IntEnum):\n    foo = -300\n    bar = 300\n\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a Enum8('hello' = -1, 'world' = 2), b Enum16('foo' = -300, 'bar' = 300)) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [(A.hello, B.bar), (A.world, B.foo), (-1, 300), (2, -300)]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### Decimal\n```python\nfrom decimal import Decimal\n\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a Decimal(9, 5)) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [(Decimal('300.42'),), (300.42,), (-300,)]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data, types_check=True)\n```\n### IP family\n`IPv4` `IPv6`\n```python\nfrom ipaddress import IPv6Address, IPv4Address\n\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a IPv4, b IPv6) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [\n    (IPv4Address(\"10.0.0.1\"), IPv6Address('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'),),\n]\nclient.execute(\"INSERT INTO demo_db.demo_tb (a, b) VALUES\", data)\n```\n### Map\n```python\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a Map(String, UInt64)) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [\n    ({},),\n    ({'key1': 1},),\n    ({'key1': 2, 'key2': 20},),\n    ({'key1': 3, 'key2': 30, 'key3': 50},)\n]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### LowCardinality\n```python\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a LowCardinality(UInt8)) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [(x,) for x in range(255)]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n### UUID\n```python\nfrom uuid import UUID\n\nclient.execute(\"CREATE TABLE demo_db.demo_tb (a UUID) ENGINE=CnchMergeTree() ORDER BY tuple()\")\ndata = [\n    (UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'),),\n    ('2efcead4-ff55-4db5-bdb4-6b36a308d8e0',)\n]\nclient.execute(\"INSERT INTO demo_db.demo_tb VALUES\", data)\n```\n## Cursor Support: DB API 2.0\nCursors are supported following DB API 2.0 specifications. Cursors are created by the connection.cursor() method. They \nare bound to the connection for the entire lifetime and all the commands are executed in the context of the database \nsession wrapped by the connection.\n```python\nfrom bytehouse_driver import connect\n\nkwargs = {}\nkwargs.setdefault('region', REGION)\nkwargs.setdefault('account', ACCOUNT)\nkwargs.setdefault('user', USER)\nkwargs.setdefault('password', PASSWORD)\n\nconnection = connect(**kwargs)\ncursor = connection.cursor()\n\ncursor.execute(\"DROP TABLE IF EXISTS cursor_tb\")\ncursor.execute(\"CREATE TABLE cursor_tb (id INT) ENGINE=CnchMergeTree() ORDER BY tuple()\")\n\ncursor.executemany(\"INSERT INTO cursor_tb (id) VALUES\", [{'id': 100}])\n\nresult_set = cursor.execute(\"SELECT * FROM cursor_tb\")\nfor result in result_set:\n    print(result)\n\nconnection.close()\n```\n## User defined query-id\nUser can manually supply query-id for each query execution. Users are encouraged to maintain uniqueness or relevancy \nof the query-id string. If not set, then server will assign a randomly generated UUID as the query-id. \n```python\nclient = Client(\n    region=self.region,\n    account=self.account,\n    user=self.user,\n    password=self.password\n)\nclient.execute(\"SELECT 1\", query_id=\"ba2e2cea-2a11-4926-a0b8-e694ded0cf65\")\n```\n## Local Development\nChange `setup.cfg` file to include your connection credentials. For running tests locally, follow these steps:\n```python\npython testsrequire.py && python setup.py develop\npy.test -v\n```\n## Issue Reporting\nIf you have found a bug or if you have a feature request, please report them at this repository issues section. \nAlternatively, you can directly create an issue with our support platform here: https://bytehouse.cloud/support\n## Original Author\nByteHouse wants to thank original author @Konstantin Lebedev & ClickHouse for original contribution to this driver. \n## License\nThis project is distributed under the terms of the MIT license: http://www.opensource.org/licenses/mit-license.php\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python driver with native interface for ByteHouse",
    "version": "1.0.4",
    "project_urls": {
        "Changes": "https://github.com/bytehouse-cloud/driver-py/blob/main/CHANGELOG.md",
        "Documentation": "https://github.com/bytehouse-cloud/driver-py",
        "Homepage": "https://github.com/bytehouse-cloud/driver-py"
    },
    "split_keywords": [
        "bytehouse",
        "db",
        "database",
        "cloud",
        "analytics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31d2f576551b398a7ea1cb2b1fafa402406167977decf5db0c1cfba268336968",
                "md5": "3a366dfc985ca20eb7981ae19dd7fb4b",
                "sha256": "8e9e67edbaed5dcfdcaa3c17b4cc67836723e76989b5f788680859b3c9e46cd6"
            },
            "downloads": -1,
            "filename": "bytehouse_driver-1.0.4-cp310-cp310-macosx_12_0_x86_64.whl",
            "has_sig": false,
            "md5_digest": "3a366dfc985ca20eb7981ae19dd7fb4b",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": "<4,>=3.6",
            "size": 236876,
            "upload_time": "2024-04-17T10:48:43",
            "upload_time_iso_8601": "2024-04-17T10:48:43.340701Z",
            "url": "https://files.pythonhosted.org/packages/31/d2/f576551b398a7ea1cb2b1fafa402406167977decf5db0c1cfba268336968/bytehouse_driver-1.0.4-cp310-cp310-macosx_12_0_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c5bcf5f090ed1a088ac8f6fbaa4066282230c6239ee181328bb421d34cfbc2de",
                "md5": "2c155c16b960f7ea2f8d0c8fc5dece84",
                "sha256": "d65e075077c6f5b7084dc9aced6b2d1baa80771efc110f544d38ac9431f22d47"
            },
            "downloads": -1,
            "filename": "bytehouse_driver-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "2c155c16b960f7ea2f8d0c8fc5dece84",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.6",
            "size": 254883,
            "upload_time": "2024-04-17T10:48:45",
            "upload_time_iso_8601": "2024-04-17T10:48:45.699628Z",
            "url": "https://files.pythonhosted.org/packages/c5/bc/f5f090ed1a088ac8f6fbaa4066282230c6239ee181328bb421d34cfbc2de/bytehouse_driver-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 10:48:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bytehouse-cloud",
    "github_project": "driver-py",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "lcname": "bytehouse-driver"
}
        
Elapsed time: 2.49532s