-
-
Notifications
You must be signed in to change notification settings - Fork 278
error when trying to use op.bulk_insert on tables with json columns #770
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
hey there - your script doesn't fail for me. Running against MySQL 8.0.21 with mysqlclient 2.0.2 (2.0.1 also worked fine), the SQL log output is as follows:
so we would say this has something to do with how the database was created, e.g. CHARACTER SET options perhaps. There's lots and lots of google hits for this error but they seem specific to some kind of bulk importer tool, but then it looks like ultimatetely you want to make sure the database itself is created with the utf8mb4 character set and not BINARY: https://stackoverflow.com/questions/36178312/mysqlimport-issues-set-character-set-database-binary-which-prevents-loading note also I'm using a URL with charset=utf8mb4:
|
note also that the mysqlclient driver formats SQL values differently when using "executemany" vs. "execute", it rewrites INSERT statements internally, so that would likely be why you get different results with more than one value vs. a single value. |
the CREATE DATABASE I'm working with is:
|
Thanks for the detailed answer) |
Removing As mentioned in the documentation, it instructs BDAPI driver to provide special character set introducers, which, apparently, break bulk inserts of rows with JSON values Still, I'm not sure if having |
thanks for that hint, can reproduce and confirmed this is a mysqlclient bug. Use PyMySQL or dont use the binary_prefix flag. Issue created at PyMySQL/mysqlclient#494 |
I am having exact error with aiomysql and also asyncmy while trying to insert json to mysql 8. So same error? |
Describe the bug
when trying to use op.bulk_insert on tables with JSON columns, if I try to insert more than one value using bulk_insert, a mysql write error occurs: (3144, "Cannot create a JSON value from a string with CHARACTER SET 'binary'.")
It occurs even if you try to insert an empty Dict
Expected behavior
No error occurs
To Reproduce
Error
Versions.
Additional context
If you insert only one value, then the error does not occur
The text was updated successfully, but these errors were encountered: