-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
'MySQLConverter' object has no attribute '_timestamp_to_mysql' error with datetime64[ns], MySQL and MySQL-connector #7936
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
Thanks for reporting! But some questions to make it more clear / easier to work with:
You can do that by just adapting your initial post. |
I also notice an other issue (if I change
|
Now code with mysql.connector and custom converter
doesn't raise any error but table index is wrong in database:
|
OK, I can reproduce this (although with a slightly different error: For the sub-second resolution, can you open a seperate issue? |
Sub-second resolution issue with mysqldb driver opened here #7938 |
With the custom converter, I get it working when using:
So returning a string instead of an int (for some reason sqlalchemy specifies it as text, although I thought mysql supported datetime types, have to check that). I only get occasional an error like |
Anyway this solution will lead to second rounding (no sub-second resolution), isn't it ? |
Correction: mysql just expects a string format for the datetime, but it is stored as a Indeed, this will round to second resolution, but as I say in the other issue, this is a limitation of mysql, not pandas. So if you want to use the |
For future reference, the problem is the following: mysql-connector has a So doing:
should also work as a workaround. |
This was closed by #8208 (apparantly github didn't do it automatically) |
Just ran into this, so I'm not sure if the issue was never actually fixed or there's been a recent regression. The workaround suggested in the thread solved my problem. |
Hello,
This code
raises following error:
I try to pass my own converter see
But I didn't have success
I think it should be nice if
datetime64[ns]
where automatically stored asBIGINT
in database.I'm aware that I can convert df column (or index) with
datetime64[ns]
(or Pandas Timestamp) data to integer data before callingto_sql
but I don't consider this as a clean way of doing.The text was updated successfully, but these errors were encountered: