Skip to content

Microsecond is not stored correctly in DateTime64 column #382

@freedom0116

Description

@freedom0116

Describe the bug
Try to insert DateTime64 data but somehow the stored data missed microsecond info.

To Reproduce
Any insert query for DateTime64 column.

Expected behavior
Should stored with microsecond information in DateTime64 column.

Here is the source code for doing the datetime handling: https://github.com/xzkostyan/clickhouse-sqlalchemy/blob/master/clickhouse_sqlalchemy/drivers/http/transport.py#L29

In datetime_converter function, there is special handling for the microseconds but not working properly. If I insert the data with the native connection the timestamp is correct, but with http way the result is not right. Confirm this is not the model setup error. Here is the result for the insert data:

Expected: [datetime.datetime(2025, 7, 2, 3, 16, 40, 768962)]
Actual: datetime.datetime(2025, 7, 2, 3, 16, 40, 0)

Versions

  • Version of package with the problem: 0.3.2
  • Python version: 3.12.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions