You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue here is that both NULL datetimes and '0000-00-00' datetimes in the context of MySQL have the same meaning in the context of MySQLdb (both are represented as None) thus data will be lost in case of (as an example) data being copied from one data base to another.
I'm not seeing a solution here - yet -, as you can't have a Datetime object with day, month and year as 0 values.
My solution, for my specific problem is this (using MySQLdb-1.2.4, installed with pip), on times.py (line 79):
defDate_or_None(s):
ifs[0:4] =='0000': # this is my solutionreturnstry: returndate(*[ int(x) forxins.split('-',2)])
except: returnNone
So I'm returning the original Datetime representation string (lines 2 and 3 of code block were added by me).
The text was updated successfully, but these errors were encountered:
It's by design (obviously), but I am considering returning MySQL date values which cannot be turned into Python dates as the original string value, for version 1.3.
I guess introducing backward-incompatible changes in minor version is generally a bad idea. Not only it may break a lot of code out there (which will be hard-to-debug as no string was expected). But also it'll make date values more inconsistent. Now it's clear that either you get datetime.datetime or NoneType for a date column value. So I think it's a special enough case for a developer who absolutely needs this quirky zero values, to either cast columns in the query to CHAR directly, or to redefine MySQLdb converters.
The issue here is that both NULL datetimes and '0000-00-00' datetimes in the context of MySQL have the same meaning in the context of MySQLdb (both are represented as None) thus data will be lost in case of (as an example) data being copied from one data base to another.
I'm not seeing a solution here - yet -, as you can't have a Datetime object with day, month and year as 0 values.
My solution, for my specific problem is this (using MySQLdb-1.2.4, installed with pip), on times.py (line 79):
So I'm returning the original Datetime representation string (lines 2 and 3 of code block were added by me).
The text was updated successfully, but these errors were encountered: