Closed mofei920 closed 10 months ago
I was able to reproduce this with Int64 but not Int32:
from chdb import dbapi
conn = dbapi.connect()
cur = conn.cursor()
cur.execute("CREATE DATABASE IF NOT EXISTS test_db ENGINE = Atomic")
cur.execute("USE test_db")
cur.execute("""
CREATE TABLE t1
(
`id` Int32,
c1 String
)
ENGINE = ReplacingMergeTree
ORDER BY id;
""")
cur.executemany("insert into t1 values (%s, %s)", [(1, "a"), (2, "b"), (3, "c")])
# Test fetchall
cur.execute("select id, c1 from t1")
rows = cur.fetchall()
print(rows)
# Clean up
cur.close()
conn.close()
According to clickhouse docs (https://clickhouse.com/docs/en/interfaces/formats#json):
For compatibility with JavaScript, Int64 and UInt64 integers are enclosed in double quotes by default. To remove the quotes, you can set the configuration parameter output_format_json_quote_64bit_integers to 0.
Seems like all we have to do is set this configuration parameter.
chdb driver version: 0.14.2 chdb version: 23.6.1.1 Python version: 3.9.6 macos catalina: 10.15.7
How to reproduce: create test table.
python code, just read data from table t1.
when i run the python code as above, i got the below result, the int id return as string, and the result returned as tuple, is it possible dbapi return result same as clickhouse_driver in python?