mirror of
https://github.com/hanzo-ds/connect.git
synced 2026-10-30 20:31:24 +00:00
Imports read `datastore_connect`, distribution `datastore-connect`, so nothing has to import another product's name to talk to Hanzo Datastore. Cut from upstream 0.8.17 — the version this stack already ran — rather than from upstream HEAD, so it is a PURE RENAME with no behaviour change. Forking from HEAD would have dragged versions along with the name (connect alone jumped 0.8.17 -> 1.6.0, a major), which is a different and much riskier change wearing a rename's clothes. X-ClickHouse-* headers are untouched: they are wire protocol the server sends and expects, and a different token shape from the module name.
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
from sqlalchemy.engine import Engine
|
|
|
|
from datastore_connect import common
|
|
|
|
test_query = """
|
|
-- 6dcd92a04feb50f14bbcf07c661680ba
|
|
WITH dummy = 2
|
|
SELECT database, name FROM system.tables LIMIT 2
|
|
-- 6dcd92a04feb50f14bbcf07c661680ba
|
|
"""
|
|
|
|
test_query_ver19 = """
|
|
-- 6dcd92a04feb50f14bbcf07c661680ba
|
|
SELECT database, name FROM system.tables LIMIT 2
|
|
-- 6dcd92a04feb50f14bbcf07c661680ba
|
|
"""
|
|
|
|
|
|
def test_dsn_config(test_engine: Engine):
|
|
common.set_setting('invalid_setting_action', 'drop')
|
|
client = test_engine.raw_connection().connection.client
|
|
assert client.http.connection_pool_kw['cert_reqs'] == 'CERT_REQUIRED'
|
|
assert 'use_skip_indexes' in client.params
|
|
assert client.params['http_max_field_name_size'] == '99999'
|
|
assert client.query_limit == 2333
|
|
assert client.compression == 'zstd'
|
|
|
|
|
|
def test_cursor(test_engine: Engine):
|
|
common.set_setting('invalid_setting_action', 'drop')
|
|
raw_conn = test_engine.raw_connection()
|
|
cursor = raw_conn.cursor()
|
|
sql = test_query
|
|
if not raw_conn.connection.client.min_version('21'):
|
|
sql = test_query_ver19
|
|
|
|
cursor.execute(sql)
|
|
assert cursor.description[0][0] == 'database'
|
|
assert cursor.description[1][1] == 'String'
|
|
assert len(getattr(cursor, 'data')) == 2
|
|
assert cursor.summary[0]["read_rows"] == '2'
|
|
raw_conn.close()
|
|
|
|
|
|
def test_execute(test_engine: Engine):
|
|
common.set_setting('invalid_setting_action', 'drop')
|
|
|
|
with test_engine.begin() as conn:
|
|
sql = test_query
|
|
if not conn.connection.connection.client.min_version('21'):
|
|
sql = test_query_ver19
|
|
rows = list(row for row in conn.execute(sql))
|
|
assert len(rows) == 2
|
|
|
|
rows = list(row for row in conn.execute('DROP TABLE IF EXISTS dummy_table'))
|
|
assert len(rows) > 0 # This is just the metadata from the "command" QueryResult
|
|
|
|
rows = list(row for row in conn.execute('describe TABLE system.columns'))
|
|
assert len(rows) > 5
|