Bug #87776 Wrong return type from fetch_all() and unknown situation:
| Submitted: | 15 Sep 2017 14:10 | Modified: | 28 Apr 2022 16:40 |
|---|---|---|---|
| Reporter: | Shahriyar Rzayev | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / Python | Severity: | S2 (Serious) |
| Version: | 8.0.4 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[15 Sep 2017 14:10]
Shahriyar Rzayev
[20 Sep 2017 12:14]
MySQL Verification Team
Hello Shahriyar, Thank you for the report and feedback. Thanks, Umesh
[20 Sep 2017 13:53]
Nuno Mariz
Hi Shahriyar,
Thank you for your report.
In fact, the documentation is not clear about this. But the reference docs refers to 'item', because it can be a 'mysqlx.DbDoc' if Collections are being used or 'mysqlx.Row' if it's a session.sql() execution.
- session.sql() will return a 'mysqlx.SqlResult' object and when 'fetch_all()' is called will return a list of 'mysqlx.Row'
- Collection.find().execute() will return a 'mysql.DocResult' object and when 'fetch_all()' is called will return a list of 'mysqlx.DbDoc'
For the 'mysqlx.Row.get_string()' method, you should provide the column name in the SQL for simplicity.
For example if you have:
command = "select count(*) as total from {}.{}"
You can do
self.session.sql(command.format(schema_name, table_name))
result = sql.execute()
for row in result.fetch_all():
print(row.get_string("total"))
or
print(row["total"])
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
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.