xzkostyan / clickhouse-sqlalchemy

ClickHouse dialect for SQLAlchemy
https://clickhouse-sqlalchemy.readthedocs.io
Other
438 stars 133 forks source link

Usage with CHDB? #279

Open yunyu opened 11 months ago

yunyu commented 11 months ago

Describe the bug Is there an easy way to use clickhouse-sqlalchemy with https://github.com/chdb-io/chdb/, for use cases like integration tests? It looks like the only available drivers are native http or asynch.

To Reproduce Try to connect with chdb using the DB-API driver, i.e. clickhouse+chdb://. The driver isn't supported

Expected behavior Sqlalchemy connects with CHDB

Versions

auxten commented 7 months ago

Hello guys, can we add chdb support to this project? chdb is an in-process version of the ClickHouse engine. Currently, chdb has already supported DB-API, and here's how to use it. I'm not a SQLAlchemy expert, so I hope to get your help:

from chdb import dbapi

conn = dbapi.connect(path="some_local_path")
cur = conn.cursor()
cur.execute("CREATE DATABASE e ENGINE = Atomic;")
cur.execute("CREATE TABLE e.hi (a String primary key, b Int32) Engine = MergeTree ORDER BY a;")
cur.execute("INSERT INTO e.hi (a, b) VALUES (%s, %s);", ["he", 32])

cur.close()
conn.close()

Also: https://github.com/chdb-io/chdb/issues/213