Skip to content
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

Pickle protocol fix #34

Closed
wants to merge 2 commits into from

Conversation

moskitos80
Copy link

Error when using Python 3 + Unicode.
Only pickle protocol version 0 and 1 can accurately convert the data to
a string, because the storage we use the "Text" type field. I was the
reason that the data is simply not saved to the database, without any errors.
In Python 3 pickle.dumps function protocol version installed by default 3.
Therefore calls pickle.dumps() to explicitly specify the protocol version 0.
This was done.

When using SQLAlchemy and Unicode fields having unique length of 256 we get
a unique index length of 256 * 3 = 768 bytes, and 767 are allowed!
This causes an error:
"sqlalchemy.exc.ProgrammingError: (mysql.connector.errors.ProgrammingError) 1071
(42000): Specified key was too long; max key length is 767 bytes"

While the length of the 255 is quite enough to store uuid4 - hashes.
Only pickle protocol version 0 and 1 can accurately convert the data to
a string, because the storage we use the "Text" type field. In Python 3
pickle.dumps function protocol version installed by default 3. Therefore
calls pickle.dumps() to explicitly specify the protocol version 0.
This was done.
@Lxstr
Copy link
Contributor

Lxstr commented Feb 25, 2024

Python 2 no longer supported

@Lxstr Lxstr closed this Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants