fix(dbapi): add PEP 249 Binary; bind Time as integer seconds - #922
Closed
sankalpsthakur wants to merge 1 commit into
Closed
fix(dbapi): add PEP 249 Binary; bind Time as integer seconds#922sankalpsthakur wants to merge 1 commit into
sankalpsthakur wants to merge 1 commit into
Conversation
sankalpsthakur
requested review from
joe-clickhouse and
peter-leonov-ch
as code owners
August 1, 2026 08:30
SQLAlchemy LargeBinary calls dialect.dbapi.Binary; expose Binary=bytes and the other PEP 249 type constructors on clickhouse_connect.dbapi. datetime.time and timedelta query/bind parameters were stringified as HH:MM:SS, which ClickHouse Time/Time64 reject (they store integer ticks). Format them as seconds since midnight / total seconds instead. Fixes ClickHouse#919
sankalpsthakur
force-pushed
the
fix/919-dbapi-binary-time
branch
from
August 1, 2026 08:37
457a509 to
7cd8803
Compare
Contributor
|
Hi @sankalpsthakur, thanks for the work here but I am closing this PR because it combines two unrelated changes. The DB API constructor fix has been re-authored as a single PR with tests and a changelog entry. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #919.
Two DB-API / SQLAlchemy Core bind gaps:
Binarymissing — SQLAlchemyLargeBinarycallsdialect.dbapi.Binary(value)and raisedAttributeErrorbecauseclickhouse_connect.dbapidid not define it. AddBinary = bytesplus the other standard PEP 249 constructors (Date,Time,Timestamp,*FromTicks).Timebinds asHH:MM:SS— ClickHouseTime/Time64store integer ticks (seconds forTime).format_query_value/format_bind_valueleftdatetime.timeandtimedeltaas bare string forms that the server rejects for Int32/Int64. Convert them to integer seconds so inserts and binds succeed.Checklist
Tests
tests/unit_tests/test_driver/test_dbapi_types.py—Binary/ PEP 249 constructorstests/unit_tests/test_driver/test_params.py— time/timedelta format_query_value, format_bind_value, finalize_query, server-side bindAI disclosure
This change was implemented with AI assistance (Grok). I reviewed the diff, aligned it with the issue suggestions and existing bind/temporal conventions, and ran the focused unit suite above.
AI/LLM disclosure