MySQL Connector/Python Developer Guide

11.13 _mysql_connector.MySQL.convert_to_mysql() Method

Syntax:

converted_obj = ccnx.convert_to_mysql(obj))

Converts a Python object to a MySQL value based on the Python type of the object. The converted object is escaped and quoted.

ccnx.query('SELECT CURRENT_USER(), 1 + 3, NOW()')
row = ccnx.fetch_row()
for col in row:
  print(ccnx.convert_to_mysql(col))
ccnx.consume_result()

Raises a MySQLInterfaceError exception if the Python object cannot be converted.