MCPcopy Create free account
hub / github.com/dbcli/mycli / get_result

Method get_result

mycli/sqlexecute.py:391–412  ·  view source on GitHub ↗

Get the current result's data from the cursor.

(self, cursor: Cursor)

Source from the content-addressed store, hash-verified

389 break
390
391 def get_result(self, cursor: Cursor) -> SQLResult:
392 """Get the current result's data from the cursor."""
393 preamble = header = None
394
395 # cursor.description is not None for queries that return result sets,
396 # e.g. SELECT or SHOW.
397 plural = '' if cursor.rowcount == 1 else 's'
398 if cursor.description:
399 header = [x[0] for x in cursor.description]
400 status = FormattedText([('', f'{cursor.rowcount} row{plural} in set')])
401 else:
402 _logger.debug("No rows in result.")
403 status = FormattedText([('', f'Query OK, {cursor.rowcount} row{plural} affected')])
404
405 if cursor.warning_count > 0:
406 plural = '' if cursor.warning_count == 1 else 's'
407 comma = FormattedText([('', ', ')])
408 warning_count = FormattedText([('class:output.status.warning-count', f'{cursor.warning_count} warning{plural}')])
409 status.extend(comma)
410 status.extend(warning_count)
411
412 return SQLResult(preamble=preamble, header=header, rows=cursor, status=status)
413
414 def tables(self) -> Generator[tuple[str], None, None]:
415 """Yields table names"""

Calls 2

SQLResultClass · 0.90
debugMethod · 0.45