Home | Trees | Indices | Help |
---|
|
object --+ | Connection
MySQL connection object.
Creating a new Connection object has the following parameters (all optional):
convert_in: A mysql.conversion.input.Input_Conversion instance to use for input parameter conversion. If not specified, defaults to the implementation in the mysql.conversion.input module.
convert_out: A mysql.conversion.output.Output_Conversion instance to use for output value conversion (when using the execute method to retrieve results, this does not apply to the statement API). If not specified, defaults to the implementation in the mysql.conversion.output module.
paramstyle: The style of parameter substitution to use in the execute method. This may be one of the following:
The default is "pytemplate".
See the mysql.conversion.input module for detail on how parameters are escaped.
|
|||
|
__init__(...) x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
||
|
__new__(T,
S,
...) Returns a new object with type S, a subtype of T... |
||
|
_param_format(...) Convert args using simple python format replacement. |
||
|
_param_pyformat(...) Convert args using python dictionary format replacement. |
||
|
_param_pytemplate(...) Convert args using python string Template replacement. |
||
|
_raise_error(...) Raise the appropriate MySQL error exception from the current MySQL error. |
||
|
_set_unbuffered_statement(...) Set the current unbuffered statement object. |
||
|
add_init_command(...) Command to execute when connecting to the MySQL server. |
||
|
change_user(...) Switch user and current database. |
||
|
commit(...) Commit the current transaction. |
||
|
connect(...) Connect to the database. |
||
|
disable_multi_statements(...) Disable the use of multiple statements. |
||
|
disconnect(...) Disconnect from the database. |
||
|
enable_multi_statements(...) Enable the support for issuing multiple statements in one call. |
||
|
escape(...) Escape arguments for a SQL statement. |
||
|
exec_container(...) Execute a statement retrieving inputs from a container. |
||
|
exec_fetch_container(...) Execute a statement retrieving inputs and storing ouputs from/to a container. |
||
|
execute(...) Issue a SQL statement. |
||
|
get_client_info(...) Return the client version as a string. |
||
|
get_client_version(...) Return the client version as an integer. |
||
|
get_current_character_set_info(...) Return information about the current character set. |
||
|
get_host_info(...) Return information about the type of connection in use. |
||
|
get_protocol_version(...) Return the protocol used by the current connection. |
||
|
get_server_info(...) Return the server version as a string. |
||
|
get_server_version(...) Return the server version as an integer. |
||
|
has_more_results(...) Return whether or not more results are available. |
||
|
kill_server_thread(...) Asks the server to kill a thread. |
||
|
last_insert_id(...) Return the last AUTO_INCREMENT id. |
||
|
last_statement_info(...) Return an informational string about the last statement executed. |
||
|
new_statement(...) Create a new Statement object. |
||
|
next_result(...) Get the next result for multi-statement execution. |
||
|
ping(...) Check if the connection to the server is working. |
||
|
rollback(...) Roll back the current transaction. |
||
|
select_db(...) Set the database to use. |
||
|
server_thread_id(...) Return the server thread ID for the current connection. |
||
|
set_charset_dir(...) Set the pathname to the directory that contains character set definition files. |
||
|
set_charset_name(...) Set the name of the character set to use as the default character set. |
||
|
set_connect_timeout(...) Set the connect timeout in seconds. |
||
|
set_current_character_set(...) Set the current character set name. |
||
|
set_default_conf_file(...) Set the configuration file to load instead of my.cnf. |
||
|
set_default_conf_group(...) Set the group in my.cnf to read from. |
||
|
set_disable_load_infile(...) Disable the "LOAD DATA LOCAL INFILE" command. |
||
|
set_enable_local_infile(...) Enable the "LOAD DATA LOCAL INFILE" command. |
||
|
set_protocol_default(...) Use the default connection protocol. |
||
|
set_protocol_memory(...) Use the shared memory connection protocol. |
||
|
set_protocol_pipe(...) Use the named pipe connection protocol (Windows). |
||
|
set_protocol_socket(...) Use the socket connection protocol (Unix). |
||
|
set_protocol_tcp(...) Use the TCP connection protocol. |
||
|
set_read_timeout(...) Set the read timeout for communicating with the server. |
||
|
set_reconnect_off(...) Do not automatically reconnect when the connection to the server is lost. |
||
|
set_reconnect_on(...) Automatically reconnect when the connection to the server is lost. |
||
|
set_secure_auth_off(...) Allow you to connect to servers that do not support the password hashing used in MySQL 4.1.1 and later. |
||
|
set_secure_auth_on(...) Only connect to servers that support the password hashing used in MySQL 4.1.1 and later. |
||
|
set_shared_memory_base_name(...) Set the name of the shared memory object for communicating with the server. |
||
|
set_use_compression(...) Use the compressed client/server protocol. |
||
|
set_write_timeout(...) Set the write timeout for communicating with the server. |
||
|
shutdown_server(...) Ask the server to shut down. |
||
|
sqlstate(...) Return the current SQL state. |
||
|
ssl_set(...) Set SSL parameters for the connection. |
||
|
status(...) Return a status string. |
||
|
warning_count(...) Return the number of warnings generated by the previous SQL statement. |
||
Inherited from |
|
|||
|
__pyx_vtable__ = <PyCObject object at 0x852e080>
|
|
|||
|
_convert_in = <member '_convert_in' of 'mysql.connection.Connectio... mysql.conversion.input.Input_Conversion instance. |
||
|
_convert_out = <member '_convert_out' of 'mysql.connection.Connecti... mysql.conversion.output.Output_Conversion instance. |
||
|
_db MYSQL database structure. |
||
|
_old_statements A _Statement_Cleaner instance for cleaning up statement structures. |
||
|
_param_formatter The _param_* method to call to format parameters based on the paramstyle argument given in __init__. |
||
|
_unbuffered_result A live mysql.result.Result instance that is not buffering results on the client side. |
||
|
_unbuffered_statement A list mysql.stmt.Statement instance that is currently retrieving results without buffering them on the client side. |
||
|
connected = <member 'connected' of 'mysql.connection.Connection'... Boolean value that indicates whether or not the connection is currently established. |
||
|
paramstyle = <member 'paramstyle' of 'mysql.connection.Connection... The paramstyle string passed in the constructor. |
|
|||
Inherited from |
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
|
Convert args using simple python format replacement. |
Convert args using python dictionary format replacement. |
Convert args using python string Template replacement. |
Raise the appropriate MySQL error exception from the current MySQL error. If there is no error, then mysql.exceptions.client.Unknown_Error is raised. Never call this when self._db is NULL. |
Set the current unbuffered statement object. This is used to keep track of which mysql.stmt.Statement object is currently live with unbuffered results. It removes the previously set Statement object. |
Command to execute when connecting to the MySQL server. Will automatically be re-executed when reconnecting (when set_reconnect_on is used). You may call this multiple times to add multiple commands. Closing a connection will clear any init commands registered. The arguments and keyword arguments behave the same as the execute method paying attention to the paramstyle specified when creating the connection object. Note that this will not allow NUL characters in the statement or values.
|
Switch user and current database. If the user cannot be authenticated or does not have permissions, the current user and database are not changed. This command always performs a ROLLBACK of any active transactions, closes all temporary tables, unlocks all locked tables and resets the state as if one had done a new connect. This happens even if the user didn't change. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Commit the current transaction. If no transaction is in progress, this does nothing. Note that the default mode of a connection is "autocommit" which makes this command not needed. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Connect to the database. Warning If a connection is already established, it will be closed and a new one created. Doing this will invalidate any live unbuffered result object or Statement objects. It also clears all state of the Connection object, including any options you have given previously, as-if a new Connection object was created.
|
Disable the use of multiple statements. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Disconnect from the database. Warning This will invalidate any live, unbuffered result objects and Statement objects! It also clears all state of the Connection object, including any options you have given, as-if a new Connection object was created. This never fails. |
Enable the support for issuing multiple statements in one call. Multiple statements can be seperated with a semicolon (;). This can also be enabled with the MULTI_STATEMENTS flag in the connect call. The execute method will return the first result. To get additional results, call the next_result method. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Escape arguments for a SQL statement. This performs the same argument substitution and character escaping that the execute method uses. The arguments and keyword arguments behave the same as the execute method paying attention to the paramstyle specified when creating the connection object.
|
Execute a statement retrieving inputs from a container. This method is similar to the execute method, except it gets its inputs from a container object instead as method parameters. The paramstyle must by "pytemplate". The variable names are obtained from the statement. It uses getattr to obtain the values from the container object.
|
Execute a statement retrieving inputs and storing ouputs from/to a container. This method is similar to the execute method, except it gets its inputs from a container object instead as method parameters. The output for one row is stored in the container object. The paramstyle must by "pytemplate". The variable names are obtained from the statement. It uses getattr to obtain the values from the container object and setattr to set them. If a column name is aliased with "AS", then the aliased name will be used for setting the value in the container.
|
Issue a SQL statement. Additional arguments and keywords are used for parameter substitution in the statement. How these are used depends on the paramstyle parameter used when creating the Connection object. Beware that the keyword store_result is not available for use since it is used by this function.
|
Return the client version as a string.
|
Return the client version as an integer.
|
Return information about the current character set.
|
Return information about the type of connection in use.
|
Return the protocol used by the current connection.
|
Return the server version as a string.
|
Return the server version as an integer.
|
Return whether or not more results are available. This is used for multiple-statement execution. You can call this method to check if more results are available.
|
Asks the server to kill a thread. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Return the last AUTO_INCREMENT id. Returns the value generated for an AUTO_INCREMENT column by the previous INSERT or UPDATE statement. Use this method after you have performed an INSERT statement into a table that contains an AUTO_INCREMENT field. More precisely, the last insert ID is updated under these conditions:
The value is affected only by statements issued within the current client connection. It is not affected by statements issued by other clients. Also note that the value of the SQL LAST_INSERT_ID() function always contains the most recently generated AUTO_INCREMENT value, and is not reset between statements because the value of that function is maintained in the server. Another difference is that LAST_INSERT_ID() is not updated if you set an AUTO_INCREMENT column to a specific non-special value. The reason for the difference between LAST_INSERT_ID() and last_insert_id is that LAST_INSERT_ID() is made easy to use in scripts while last_insert_id tries to provide a little more exact information of what happens to the AUTO_INCREMENT column.
|
Return an informational string about the last statement executed. The format of the string varies depending on the type of query, as described here. The numbers are illustrative only; the string contains values appropriate for the query.
|
Create a new Statement object. See mysql.stmt for more detail on using the statement API.
|
Get the next result for multi-statement execution. When executing multiple statements at once, the execute method will return the first result for the first statement. You may then call this method repeatedly to get the next result. See the module docstring for more detail about handling multiple results. See the execute method for more detail about the return value. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Check if the connection to the server is working. If the connection has gone down, an automatic reconnection is attempted (if set_reconnect_on is used). This function can be used by clients that remain idle for a long while, to check whether the server has closed the connection and reconnect if necessary. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Roll back the current transaction. If no transaction is in progress, this does nothing. Note that the default mode of a connection is "autocommit" which makes this command not needed. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Set the database to use. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Return the server thread ID for the current connection. The thread ID may be used with the kill_server_thread method. Note that some methods may cause an automatic reconnection attempt, which causes the thread ID to change. This means you should not get the thread ID and store it for later. You should get it when you need it.
|
Set the pathname to the directory that contains character set definition files. Will only take effect on the next connection attempt.
|
Set the name of the character set to use as the default character set. Will only take effect on the next connection attempt.
|
Set the connect timeout in seconds. Will only take effect on the next connection attempt.
|
Set the current character set name. This is similar to the SET NAMES statement. The connection collation becomes the default collation of the character set. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Set the configuration file to load instead of my.cnf. Will only take effect on the next connection attempt.
|
Set the group in my.cnf to read from. Will only take effect on the next connection attempt.
|
Disable the "LOAD DATA LOCAL INFILE" command. Will only take effect on the next connection attempt. See notes in set_enable_local_infile for more detail. |
Enable the "LOAD DATA LOCAL INFILE" command. Will only take effect on the next connection attempt. This option is only available if your MySQL installation was compiled to support it (with --enable-local-infile) and the MySQL server or client configuration files have not explicitly disabled its support (with --local-infile=0). If it is not supported, you will get a mysql.exceptions.Not_Allowed_Command exception when you try to execute the statement. |
Use the default connection protocol. Will only take effect on the next connection attempt. |
Use the shared memory connection protocol. Will only take effect on the next connection attempt. |
Use the named pipe connection protocol (Windows). Will only take effect on the next connection attempt. |
Use the socket connection protocol (Unix). Will only take effect on the next connection attempt. |
Use the TCP connection protocol. Will only take effect on the next connection attempt. |
Set the read timeout for communicating with the server. Will only take effect on the next connection attempt.
|
Do not automatically reconnect when the connection to the server is lost. This is the default. This must be called after a connection is established.
|
Automatically reconnect when the connection to the server is lost. Note that it will not attempt to reconnect if the connection is in the middle of a transaction. Calls that need to interact with the server will immediately raise mysql.exceptions.Server_Gone_Error. This must be called after a connection is established.
|
Allow you to connect to servers that do not support the password hashing used in MySQL 4.1.1 and later. Will only take effect on the next connection attempt. This is the default (unless overridden by a configuration file). |
Only connect to servers that support the password hashing used in MySQL 4.1.1 and later. Will only take effect on the next connection attempt. |
Set the name of the shared memory object for communicating with the server. Will only take effect on the next connection attempt.
|
Use the compressed client/server protocol. Will only take effect on the next connection attempt. |
Set the write timeout for communicating with the server. Will only take effect on the next connection attempt.
|
Ask the server to shut down. You must have SHUTDOWN privileges to run this command. Note: This will close any live unbuffered result objects and reset any live statement objects.
|
Return the current SQL state. The error code consists of five characters. '00000' means "no error". The values are specified by ANSI SQL and ODBC. Note that not all MySQL errors are mapped to SQLSTATE error codes. The value 'HY000' (general error) is used for unmapped errors.
|
Set SSL parameters for the connection. This applies to the next call to connect. Errors are not returned until you try to connect. All parameters are optional.
|
Return a status string.
|
Return the number of warnings generated by the previous SQL statement. Issue the SHOW WARNINGS statement to see what the warnings actually are.
|
|
__pyx_vtable__
|
|
_convert_inmysql.conversion.input.Input_Conversion instance. (Read only.)
|
_convert_outmysql.conversion.output.Output_Conversion instance. (Read only.)
|
_dbMYSQL database structure. May be NULL. (C only.) |
_old_statementsA _Statement_Cleaner instance for cleaning up statement structures. (C only). |
_param_formatterThe _param_* method to call to format parameters based on the paramstyle argument given in __init__. (C only.) |
_unbuffered_resultA live mysql.result.Result instance that is not buffering results on the client side. This is monitored so that it can be closed whenever an operation is performed that would reset the state of the connection. (C only.) |
_unbuffered_statementA list mysql.stmt.Statement instance that is currently retrieving results without buffering them on the client side. This is monitored so that it can be closed whenever an operation is performed that would reset the state of the connection. (C only.) |
connectedBoolean value that indicates whether or not the connection is currently established. (Read only.)
|
paramstyleThe paramstyle string passed in the constructor.
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0alpha3 on Sun Nov 12 20:01:28 2006 | http://epydoc.sourceforge.net |