MySQL Forums
Forum List  »  Connector/Python

Re: Python Connector gives incorrect result
Posted by: Oscar Pacheco
Date: April 08, 2024 10:56AM

Hi Jim,

Thanks for reaching us.

It seems a usage issue. Please, see https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor-execute.html.

Showcasing unexpected and expected usage:
```
script_dummy = """
SELECT @@version;
USE mysql;
SELECT 'foo';
"""

UNEXPECTED_USAGE = False

with cpy.connect(**config) as cnx:
with cnx.cursor() as cur:
if UNEXPECTED_USAGE:
cur.execute(script_dummy, multi=True)
result = cur.fetchall()
print(len(result))
# output on console
# ------------------
# 0
else:
for res in cur.execute(script_dummy, multi=True):
print(res.statement, res.fetchall())
# output on console
# ------------------
# SELECT @@version [('8.2.0-commercial',)]
# USE mysql []
# SELECT 'foo' [('foo',)]
```

Please, try the expected usage and let me know how it goes. In case you get bad/wrong results, please help us by providing the layout/footprint of tables `node__body` and `node__field_card_display` so we can run a precise verification.

Reagards.

Options: ReplyQuote


Subject
Written By
Posted
Re: Python Connector gives incorrect result
April 08, 2024 10:56AM


Sorry, only registered users may post in this forum.

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.