Versions
- clickhouse-connect 1.6.0
- SQLAlchemy 2.0.51
- Python 3.12.9, macOS
- Server:
clickhouse/clickhouse-server:25.3
Two Core types can't be bound through the driver. Neither is a ClickHouse limitation — the database handles both fine — so I'm reporting them together, though the causes are different.
1. LargeBinary — the PEP 249 Binary constructor is missing
clickhouse_connect.dbapi doesn't define Binary. SQLAlchemy's bind processor calls it and gets:
AttributeError: module 'clickhouse_connect.dbapi' has no attribute 'Binary'
before any statement is sent. PEP 249 lists Binary among the constructors a module must supply, alongside Date, Time, Timestamp and the rest.
ClickHouse stores binary perfectly well — String holds arbitrary bytes — so this is purely the DBAPI layer being incomplete.
2. Time — the column is created and then refuses every value
TIME is a real ClickHouse type, stored as an integer number of seconds, and the column gets created without complaint. But a Python time reaches the server as the bare literal 14:30:00 where an Int64 is expected, and the insert fails to parse.
A column that exists and rejects every value is a slightly worse outcome than one that couldn't be created, because it looks fine until you write to it. I've had to declare Time unstorable on this dialect for that reason.
Suggested fixes
For the first: add Binary to clickhouse_connect.dbapi — it can be as thin as Binary = bytes, which is what several other drivers do.
For the second: convert a datetime.time to seconds since midnight in the bind path, matching the storage the server expects.
Happy to test either against my setup.
Versions
clickhouse/clickhouse-server:25.3Two Core types can't be bound through the driver. Neither is a ClickHouse limitation — the database handles both fine — so I'm reporting them together, though the causes are different.
1.
LargeBinary— the PEP 249Binaryconstructor is missingclickhouse_connect.dbapidoesn't defineBinary. SQLAlchemy's bind processor calls it and gets:before any statement is sent. PEP 249 lists
Binaryamong the constructors a module must supply, alongsideDate,Time,Timestampand the rest.ClickHouse stores binary perfectly well —
Stringholds arbitrary bytes — so this is purely the DBAPI layer being incomplete.2.
Time— the column is created and then refuses every valueTIMEis a real ClickHouse type, stored as an integer number of seconds, and the column gets created without complaint. But a Pythontimereaches the server as the bare literal14:30:00where anInt64is expected, and the insert fails to parse.A column that exists and rejects every value is a slightly worse outcome than one that couldn't be created, because it looks fine until you write to it. I've had to declare
Timeunstorable on this dialect for that reason.Suggested fixes
For the first: add
Binarytoclickhouse_connect.dbapi— it can be as thin asBinary = bytes, which is what several other drivers do.For the second: convert a
datetime.timeto seconds since midnight in the bind path, matching the storage the server expects.Happy to test either against my setup.