MySQL Forums
Forum List  »  Connector/Python

OverflowError: Python int too large to convert to C long
Posted by: Zhi-Ming Sun
Date: October 07, 2022 02:59PM

Hi,
Can someone help me with this problem?

The code below I ran on python 3.9.7 with mysql-connector-python 8.0.23 has no any problem.

#########################################################################
import mysqlx

ss = mysqlx.get_session({'host':'localhost', 'port':33060, 'user':'root', 'password':'xxxx'})
ss.drop_schema('testx')
ss.create_schema('testx')

db = ss.get_schema('testx')
db.create_collection('test')

col = db.get_collection('test')
col.add({'_id':'test', 'item':2147483648}).execute() # 8.0.23 pass, but 8.0.24 ~ 8.0.30 fail
#col.add({'_id':'test', 'item':2147483647}).execute() # this line is OK for any version

ss.drop_schema('testx')
ss.close()
#########################################################################

But, after I upgrading mysql-connector-python to 8.0.24 ~ 8.0.30(python version is 3.10.7),
it runs fail with the following error message.

-------------------------------------------------------------------------
OverflowError: Python int too large to convert to C long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "R:\test.py", line 12, in <module>
col.add({'_id':'test', 'item':2147483648}).execute() # 8.0.23 pass, but 8.0.30 fail
File "C:\Users\zmsun\AppData\Local\Programs\Python\Python310\lib\site-packages\mysqlx\statement.py", line 711, in execute
return self._connection.send_insert(self)
File "C:\Users\zmsun\AppData\Local\Programs\Python\Python310\lib\site-packages\mysqlx\connection.py", line 494, in wrapper
result = func(self, *args, **kwargs)
File "C:\Users\zmsun\AppData\Local\Programs\Python\Python310\lib\site-packages\mysqlx\connection.py", line 1150, in send_insert
self.protocol.send_msg(msg_type, msg)
File "C:\Users\zmsun\AppData\Local\Programs\Python\Python310\lib\site-packages\mysqlx\protocol.py", line 835, in send_msg
self._writer.write_message(mysqlxpb_enum(msg_type), msg)
File "C:\Users\zmsun\AppData\Local\Programs\Python\Python310\lib\site-packages\mysqlx\protocol.py", line 268, in write_message
msg_size = msg.byte_size(msg)
File "C:\Users\zmsun\AppData\Local\Programs\Python\Python310\lib\site-packages\mysqlx\protobuf\__init__.py", line 541, in byte_size
else len(encode_to_bytes(msg.serialize_to_string()))
File "C:\Users\zmsun\AppData\Local\Programs\Python\Python310\lib\site-packages\mysqlx\protobuf\__init__.py", line 489, in serialize_to_string
return Protobuf.mysqlxpb.serialize_message(self._msg)
SystemError: <built-in function serialize_message> returned a result with an exception set
-------------------------------------------------------------------------

Is there anything I can change to fix this? Thanks.

Options: ReplyQuote


Subject
Written By
Posted
OverflowError: Python int too large to convert to C long
October 07, 2022 02:59PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.