chdb-io / chdb

chDB is an in-process OLAP SQL Engine 🚀 powered by ClickHouse
https://clickhouse.com/docs/en/chdb
Apache License 2.0
2.03k stars 72 forks source link

Feature Request: chdb.exec() function #26

Closed lmangani closed 1 year ago

lmangani commented 1 year ago

As discussed in discord, we are considering adding an exec command to pre-provision any SET parameters, UDF functions, etc with full persistence within a chdb session.

import chdb
exec = chdb.exec("CREATE FUNCTION hello AS () -> 'chDB'")
ret = chdb.query("SELECT hello()", "CSV")
print(ret.get_memview().tobytes())

Thread open for discussion and implementation proposals.

lmangani commented 1 year ago

Completed by session feature in 0.11.4+

from chdb import session as chs
## Create DB, Table, View in temp session, auto cleanup when session is deleted.
sess = chs.Session()
sess.query(""CREATE FUNCTION hello AS () -> 'chDB'")
print(sess.query("SELECT hello()", "Pretty"))