Search Results
https://dev.mysql.com/doc/connectors/en/connector-python-api-mysqlconnection-database.html
>>> cnx.database = 'test' >>> cnx.database = 'mysql' >>> cnx.database u'mysql' Returns a string. This property sets the current (default) database by executing a USE statement. The property can also be used to retrieve the current database name.
https://dev.mysql.com/doc/connectors/en/connector-python-api-mysqlconnection-is-connected.html
This method checks whether the connection to MySQL is available using the ping() method, but unlike ping(), is_connected() returns True when the connection is available, False otherwise.
https://dev.mysql.com/doc/connectors/en/connector-python-api-mysqlconnection-ping.html
Syntax: cnx.ping(reconnect=False, attempts=1, delay=0) Check whether the connection to the MySQL server is still available. When reconnect is set to True, one or more attempts are made to try to reconnect to the MySQL server, and these options are ...Use the delay argument (seconds) if you want to wait between each ...
https://dev.mysql.com/doc/connectors/en/connector-python-api-mysqlconnection-raise-on-warnings.html
Note You might always want to set the SQL mode if you would like to have the MySQL server directly report warnings as errors (see Section 6.9.2.52, “MySQLConnection.sql_mode Property”). mysql.connector.errors.DataError: 1292: Truncated incorrect ... This property can be assigned a value of True or False to enable or disable whether warnings should raise ...
https://dev.mysql.com/doc/connectors/en/connector-python-api-mysqlconnection-set-charset-collation.html
In the following example, we set the character set to latin1 and the collation to latin1_swedish_ci (the default collation for: latin1): >>> cnx = mysql.connector.connect(user='scott') >>> cnx.set_charset_collation('latin1') Specify a given ...
https://dev.mysql.com/doc/connectors/en/connector-python-api-mysqlcursor-with-rows.html
Syntax: boolean = cursor.with_rows This read-only property returns True or False to indicate whether the most recently executed operation could have produced rows. The with_rows property is useful when it is necessary to determine whether a ...
https://dev.mysql.com/doc/connectors/en/connector-python-api-mysqlcursordict.html
The keys for each dictionary object are the column names of the MySQL result. Example: cnx = mysql.connector.connect(database='world') cursor = cnx.cursor(dictionary=True) cursor.execute("SELECT * FROM country WHERE Continent = 'Europe'") ...It may ...
https://dev.mysql.com/doc/connectors/en/connector-python-examples.html
These coding examples illustrate how to develop Python applications and scripts which connect to MySQL Server using MySQL Connector/Python.
https://dev.mysql.com/doc/connectors/en/connector-python-logging.html
By default, logging functionality follows the default Python logging behavior. If logging functionality is not configured, only events with a severity level of WARNING and greater are printed to sys.stderr. For related information, see Python's ...
https://dev.mysql.com/doc/connectors/en/connector-python-multi.html
with cnx.cursor() as cur: # Execute SQL; it can contain one or multiple statements cur.execute(sql_operation, map_results=True) # Fetch result set, see other examples for additional information A MySQL multi statement or script is composed of one or ... Connector/Python can execute either a single or multiple statements, this section references multiple statement and associated delimiter ...