Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
-
MariaDB Connector/Python 2.0.0rc2
Python 3.13.5
MariaDB Server 12.3.2-MariaDB-ubu2404-log (Ubuntu 24.04)
-
3.13.5
Description
Summary
Connector/Python 2.0.0rc2 serializes a timezone-aware Python datetime through the text protocol with its UTC offset (for example 2026-08-14 04:00:00+00:00). MariaDB DATETIME does not accept that representation, so an insert/update that worked with Connector/Python 1.1.14 now fails with error 1292.
Connector/Python 1.1 documented/implemented timezone information on datetime values as being ignored/removed. The 2.0 behavior is therefore a backward-incompatible change for applications passing aware datetimes.
Reproducer
from datetime import datetime, timezone |
import mariadb |
|
|
con = mariadb.connect( |
host="localhost", |
user="...", |
password="...", |
database="test" |
)
|
cur = con.cursor() |
cur.execute("CREATE TEMPORARY TABLE t (d DATETIME NOT NULL)") |
cur.execute(
|
"INSERT INTO t (d) VALUES (?)", |
(datetime(2026, 8, 14, 4, 0, tzinfo=timezone.utc),) |
)
|
Actual result
Incorrect datetime value: '2026-08-14 04:00:00+00:00' for column `test`.`t`.`d` at row 1 (errno: 1292, sqlstate: 22007)
|
The same problem occurred in the real table `rhttst`.`RHTHST`.`HSTOTM`.
Expected result
Please provide a targeted, documented compatibility option for timezone-aware datetime parameters instead of requiring the entire connection to use binary=True. For example, a connection option with policies such as:
- reject — explicitly reject aware datetime values on the client
- strip — retain the Connector/Python 1.1 behavior
- utc — convert to UTC and then remove tzinfo before binding to a MariaDB DATETIME
The migration guide should also explicitly document this behavior change and its effect on DATETIME parameters.
Impact and workarounds
Existing applications can stop writing datetime values immediately after upgrading from 1.1.14 to 2.0.0rc2. Setting binary=True for the full connection changes protocol/prepared-statement behavior for every query, which is broader than necessary.
Current workarounds are to remain on Connector/Python 1.1.14 or normalize each value in application code, for example:
value.astimezone(timezone.utc).replace(tzinfo=None) |