questdb / questdb-connect

SQLAchemy and Apache Superset extensions for QuestDB
Apache License 2.0
14 stars 6 forks source link

questdb_connect calls time.tzset(), affects global behavior and inconsistent with SQLAlchemy defaults #12

Closed Quantizr closed 2 months ago

Quantizr commented 4 months ago

https://github.com/questdb/questdb-connect/blob/654b1b6d096d0d521e9d66736ab0e7f1d228da27/src/questdb_connect/__init__.py#L41-L48

I understand the reasoning for wanting to set the default TZ to UTC, however, the critical issue here is that time.tzset() reinitializes the time conversion rules for the entire Python process, not just the questdb_connect module. This affects all time-related operations in any package or module that is part of the same Python environment, breaking assumptions about default time behavior.

The new time conversion rules also happen at the time at which questdb_connect is imported, which may not be at the start of a project, causing an unexpected change which could be difficult to debug. time.tzset() is also not present on all systems, leading to inconsistent behavior between operating systems.

SQLAlchemy by default is timezone naive and allows the user to handle timezones and conversions, so an extension should probably keep the same behavior and only recommend the user use UTC rather than set it by default. Switching a database to QuestDB on SQLAlchemy shouldn't require changing all DateTime and timezone related functions or resetting the timezone to default.