MySQL Connector/Python Developer Guide

11.10 _mysql_connector.MySQL.connect() Method

Syntax:

ccnx.connect(args)

Connects to a MySQL server.

import _mysql_connector

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

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.