Documentation Home
MySQL Connector/Python Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 0.6Mb
PDF (A4) - 0.6Mb
HTML Download (TGZ) - 83.0Kb
HTML Download (Zip) - 95.6Kb

MySQL Connector/Python Developer Guide  /  Connector/Python C Extension API Reference  /  _mysql_connector.MySQL.connect() Method

11.10 _mysql_connector.MySQL.connect() Method



Connects to a MySQL server.

import _mysql_connector

ccnx = _mysql_connector.MySQL()
ccnx.connect(user='scott', password='password',
             host='', database='employees')

connect() supports the following arguments: host, user, password, database, port, unix_socket, client_flags, ssl_ca, ssl_cert, ssl_key, ssl_verify_cert, compress. See Section 7.1, “Connector/Python Connection Arguments”.

If ccnx is already connected, connect() discards any pending result set and closes the connection before reopening it.

Raises a TypeError exception if any argument is of an invalid type.

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.