MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / Connection

Class Connection

pymysql/connections.py:94–1264  ·  view source on GitHub ↗

Representation of a socket with a mysql server. The proper way to get an instance of this class is to call connect(). Establish a connection to the MySQL database. Accepts several arguments: :param host: Host where the database server is located. :param user: Username

Source from the content-addressed store, hash-verified

92
93
94class Connection:
95 """
96 Representation of a socket with a mysql server.
97
98 The proper way to get an instance of this class is to call
99 connect().
100
101 Establish a connection to the MySQL database. Accepts several
102 arguments:
103
104 :param host: Host where the database server is located.
105 :param user: Username to log in as.
106 :param password: Password to use.
107 :param database: Database to use, None to not use a particular one.
108 :param port: MySQL port to use, default is usually OK. (default: 3306)
109 :param bind_address: When the client has multiple network interfaces, specify
110 the interface from which to connect to the host. Argument can be
111 a hostname or an IP address.
112 :param unix_socket: Use a unix socket rather than TCP/IP.
113 :param read_timeout: The timeout for reading from the connection in seconds.
114 (default: None - no timeout)
115 :param write_timeout: The timeout for writing to the connection in seconds.
116 (default: None - no timeout)
117 :param str charset: Charset to use. "utf8" (or "utf8mb4") is recommended.
118 legacy multibyte encodings may pose security risks.
119 Do not use such encodings for public-facing systems.
120 :param str collation: Collation name to use.
121 :param sql_mode: Default SQL_MODE to use.
122 :param read_default_file:
123 Specifies my.cnf file to read these parameters from under the [client] section.
124 :param conv:
125 Conversion dictionary to use instead of the default one.
126 This is used to provide custom marshalling and unmarshalling of types.
127 See converters.
128 :param use_unicode:
129 Whether or not to default to unicode strings.
130 This option defaults to true.
131 :param client_flag: Custom flags to send to MySQL. Find potential values in constants.CLIENT.
132 :param cursorclass: Custom cursor class to use.
133 :param init_command: Initial SQL statement to run when connection is established.
134 :param connect_timeout: The timeout for connecting to the database in seconds.
135 (default: 10, min: 1, max: 31536000)
136 :param ssl: An ssl.SSLContext, or a dict of arguments similar to mysql_ssl_set()'s parameters.
137 Passing a dict is deprecated; use the individual ``ssl_*`` parameters or an
138 ``ssl.SSLContext`` instead.
139 :param ssl_ca: Path to the file that contains a PEM-formatted CA certificate.
140 :param ssl_cert: Path to the file that contains a PEM-formatted client certificate.
141 :param ssl_disabled: A boolean value that disables usage of TLS. Unlike other SSL options,
142 setting this to True explicitly prohibits the use of TLS, even if the server supports it.
143 :param ssl_key: Path to the file that contains a PEM-formatted private key for
144 the client certificate.
145 :param ssl_key_password: The password for the client certificate private key.
146 :param ssl_verify_cert: Set to true to check the server certificate's validity.
147 :param ssl_verify_identity: Set to true to check the server's identity.
148 :param read_default_group: Group to read from in the configuration file.
149 :param autocommit: Autocommit mode. None means use server default. (default: False)
150 :param local_infile: Boolean to enable the use of LOAD DATA LOCAL command. (default: False)
151 :param max_allowed_packet: Max size of packet sent to server in bytes. (default: 16MB)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected