chdb-io / chdb

chDB is an in-process OLAP SQL Engine 🚀 powered by ClickHouse
https://doc.chdb.io
Apache License 2.0
1.84k stars 71 forks source link

can support jdbc bridge? #215

Open wonb168 opened 1 month ago

wonb168 commented 1 month ago

has a clickhouse-jdbc-bridge,can chdb support this?

auxten commented 1 month ago

You can use the jdbc table function: https://clickhouse.com/docs/en/sql-reference/table-functions/jdbc

wonb168 commented 1 month ago

此表函数需要单独的 clickhouse-jdbc-bridge 程序才能运行?

auxten commented 1 month ago

You don't need a standalone clickhouse-jdbc-bridge

wonb168 commented 1 month ago

I tested, need install and start jdbc-bridge first:

#%%
import chdb
print(chdb.__version__)
# %%
#postgres://hvycjfbu:xVPOX-3ftwx3Mi9DJ_u-iBaN8bIwJXQt@john.db.elephantsql.com:5432/hvycjfbu
url="jdbc:postgres://hvycjfbu:xVPOX-3ftwx3Mi9DJ_u-iBaN8bIwJXQt@john.db.elephantsql.com:5432/hvycjfbu"
sql="select version()"
sql=f"""SELECT * FROM jdbc('{url}', '${sql}')"""
res = chdb.query(sql, 'Dataframe')
print(res)
# %%

raise error:

ChdbError: Code: 410. DB::Exception: clickhouse-jdbc-bridge is not running. Please, start it manually. (EXTERNAL_SERVER_IS_NOT_RESPONDING)
auxten commented 3 weeks ago

I did double check in the code. It seems JDBC will need clickhouse-jdbc-bridge started first, but ODBC does not need.