clickhouse-sqlalchemy icon indicating copy to clipboard operation
clickhouse-sqlalchemy copied to clipboard

Problem with http protocol in clickhouse-sqlalchemy 0.1.5

Open hodgesrm opened this issue 3 years ago • 3 comments

Describe the bug I'm using clickhouse-sqlalchemy 0.2.0 from pypi.org and have been unable to get http protocol to work properly. If I provide a URL like http://demo:demo@localhost:8123/default the engine.execute() method does not return data. It works fine for native protocol, e.g, a URL like 'clickhouse+native://demo:demo@localhost/default'.

To Reproduce

from sqlalchemy import create_engine
urls = ['clickhouse+native://demo:demo@localhost/default', 
        'clickhouse+http://demo:demo@localhost:8123/default',
        'clickhouse://demo:demo@localhost:8123/default']

for url in urls:
  print(f'URL: {url}')
  engine = create_engine(url, echo=False)
  print(f'Engine name: {engine.name}')
  print(f'Engine dialect: {engine.dialect}')
  df = engine.execute(f"SELECT version(), hostName(), '{url}'").fetchall()
  print(df)

Expected behavior I would expect that each type I call engine.execute() I should get back results from the call including ClickHouse version, hostname, and the url I was using. Instead I get empty arrays for calls with http protocol. The native driver works fine. The query is getting to ClickHouse in all cases--I can see it in the logs.

$ python3 check-urls-ch.py 
URL: clickhouse+native://demo:demo@localhost/default
Engine name: clickhouse
Engine dialect: <clickhouse_sqlalchemy.drivers.native.base.ClickHouseDialect_native object at 0x7f91ceadf550>
[('21.1.2.15', 'hoodoo', 'clickhouse+native://demo:demo@localhost/default')]
URL: clickhouse+http://demo:demo@localhost:8123/default
Engine name: clickhouse
Engine dialect: <clickhouse_sqlalchemy.drivers.http.base.ClickHouseDialect_http object at 0x7f91cc900310>
[]
URL: clickhouse://demo:demo@localhost:8123/default
Engine name: clickhouse
Engine dialect: <clickhouse_sqlalchemy.drivers.http.base.ClickHouseDialect_http object at 0x7f91caac1e50>
[]

Versions Here are my versions:

pip freeze |grep clickhouse
clickhouse-driver==0.2.0
clickhouse-sqlalchemy==0.1.5

hodgesrm avatar Mar 03 '21 04:03 hodgesrm

I also tried with the most up-to-date version by running pip install https://github.com/xzkostyan/clickhouse-sqlalchemy. Same result.

hodgesrm avatar Mar 03 '21 04:03 hodgesrm

Following up on this issue... Is HTTPS officially supported in clickhouse-sqlalchemy? If so I'll retest and confirm whether this has gone away. Thanks!

hodgesrm avatar May 29 '22 15:05 hodgesrm

Good point.

I'll mark HTTP driver in clickhouse-sqlalchemy as no longer supported in further releases. However HTTP interface is supported in ClickHouse server and you can use plain curl. There is not enough support from clickhouse-sqlalchemy.

So, I suppose we can close this issue.

xzkostyan avatar Jun 01 '22 09:06 xzkostyan