Documentation Home
MySQL Connector/Python Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 0.7Mb
PDF (A4) - 0.7Mb

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.