-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
dates are returned as None #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I haven't know MySQL allows such a broken date...
|
Maybe, as a simple solution for now, just return it as a string in that case? Maybe there are also other datetime-like libraries which support a data structure which allows this, but I don't know any and this would add another dependency so that might not be an option. |
Hm, But doesn't it break compatibility? Some existing code (ORMs) may not expect string is returned for date column. Additionally, is the date is supported by MySQL when sql_mode is strict? |
|
I think you shouldn't use date column type, string or integer is better. |
I agree that this might be cleaner, however, I have an existing DB without |
I think peewee also supports strings, as it could get strings from some other DB backends. |
peewee is not only user of PyMySQL.
|
FWIW I have a MySQL database that I've been using for years, with no special configuration, which has always accepted dates like It'd be good to have the stuff about customising the converters, and why you might want to do so, in the documentation. |
I'm not good at English. Writing English is 1000x harder than writing Python. |
I still open this because I feel "fallback to string" is acceptable idea. |
Including how to disable conversion for specific types. For PyMySQL#520
MySQL 5.7; db with NO_ZERO_IN_DATE eliminated from default. Python 3.6 using Alchemy will find "1920-00-00" when specifically requested as "SELECT history-date FROM table;" but "SELECT * FROM table;" brings back a null. Using variable dict. |
I have a table with a column of type date with entries like
2016-00-00
(only partially set, e.g. the year only). pymysql fails to return this.Will print only
(None,)
.I also reported this for peewee although it looks like this is a bug on pymysql side but I'm not exactly sure.
A work around is to use
which will return the date as a string (e.g. it prints
("2016-00-00",)
).The text was updated successfully, but these errors were encountered: