Home | Trees | Index | Help |
---|
Module _mysql :: Class connection |
|
object
--+
|
connection
Connection
Returns a MYSQL connection object. Exclusive use of keyword parameters strongly recommended. Consult the MySQL C API documentation for more details.
Method Summary | |
---|---|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
x.__repr__() <==> repr(x) | |
Return number of rows affected by the last query. | |
Set the autocommit mode. | |
Changes the user and causes the database specified by db to become the default (current) database on the connection specified by mysql. | |
Returns the default character set for the current connection. | |
Close the connection. | |
Commits the current transaction | |
Instructs the server to write some debug information to the log. | |
Returns the error code for the most recently invoked API function that can succeed or fail. | |
Returns the error message for the most recently invoked API function that can succeed or fail. | |
using mapping dict to provide quoting functions for each type. | |
Use connection.escape_string(s), if you use it at all. | |
Returns the number of columns for the most recent query on the connection. | |
Returns a dict with information about the current character set: | |
Returns a string that represents the MySQL client library version. | |
Returns an unsigned integer representing the protocol version used by the current connection. | |
Returns a string that represents the server version number. | |
Retrieves a string providing information about the most recently executed query. | |
Returns the ID generated for an AUTO_INCREMENT column by the previous query. | |
Asks the server to kill the thread specified by pid. | |
If more query results exist, next_result() reads the next query results and returns the status back to application. | |
Checks whether or not the connection to the server is working. | |
Execute a query. | |
Rolls backs the current transaction | |
Causes the database specified by db to become the default (current) database on the connection specified by mysql. | |
Sets the default character set for the current connection. | |
for the connection. | |
Asks the database server to shut down. | |
Returns a string containing the SQLSTATE error code for the last error. | |
Returns a character string containing information similar to that provided by the mysqladmin status command. | |
Returns a result object acquired by mysql_store_result (results stored in the client). | |
This means, any special SQL characters are escaped, and it is enclosed within single quotes. | |
Returns the thread ID of the current connection. | |
Returns a result object acquired by mysql_use_result (results stored in the server). | |
Returns the number of warnings generated during execution of the previous SQL statement. | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Class Variable Summary | |
---|---|
member_descriptor |
client_flag = <member 'client_flag' of '_mysql.connectio...
|
member_descriptor |
converter = <member 'converter' of '_mysql.connection' o...
|
member_descriptor |
open = <member 'open' of '_mysql.connection' objects>
|
member_descriptor |
port = <member 'port' of '_mysql.connection' objects>
|
member_descriptor |
server_capabilities = <member 'server_capabilities' of '...
|
Method Details |
---|
__init__(...)
|
__new__(T, S, ...)T.__new__(S, ...) -> a new object with type S, a subtype of T
|
__repr__(x)
|
affected_rows(...)Return number of rows affected by the last query. Non-standard. Use Cursor.rowcount. |
autocommit(...)Set the autocommit mode. True values enable; False value disable. |
change_user(...)Changes the user and causes the database specified by db to become the default (current) database on the connection specified by mysql. In subsequent queries, this database is the default for table references that do not include an explicit database specifier. This function was introduced in MySQL Version 3.23.3. Fails unless the connected user can be authenticated or if he doesn't have permission to use the database. In this case the user and database are not changed. The db parameter may be set to None if you don't want to have a default database. |
character_set_name(...)Returns the default character set for the current connection. Non-standard. |
close(...)Close the connection. No further activity possible. |
commit(...)Commits the current transaction |
dump_debug_info(...)Instructs the server to write some debug information to the log. The connected user must have the process privilege for this to work. Non-standard. |
errno(...)Returns the error code for the most recently invoked API function that can succeed or fail. A return value of zero means that no error occurred. |
error(...)Returns the error message for the most recently invoked API function that can succeed or fail. An empty string () is returned if no error occurred. |
escape(obj, dict)using mapping dict to provide quoting functions for each type. Returns a SQL literal string. |
escape_string(s)Use connection.escape_string(s), if you use it at all. _mysql.escape_string(s) cannot handle character sets. You are probably better off using connection.escape(o) instead, since it will escape entire sequences as well as strings. |
field_count(...)Returns the number of columns for the most recent query on the connection. Non-standard. Will probably give you bogus results on most cursor classes. Use Cursor.rowcount. |
get_character_set_info(...)Returns a dict with information about the current character set:
Not all keys may be present, particularly dir. Non-standard. |
get_host_info(...)Returns a string that represents the MySQL client library version. Non-standard. |
get_proto_info(...)Returns an unsigned integer representing the protocol version used by the current connection. Non-standard. |
get_server_info(...)Returns a string that represents the server version number. Non-standard. |
info(...)Retrieves a string providing information about the most recently executed query. Non-standard. Use messages or Cursor.messages. |
insert_id(...)Returns the ID generated for an AUTO_INCREMENT column by the previous query. Use this function after you have performed an INSERT query into a table that contains an AUTO_INCREMENT field. Note that this returns 0 if the previous query does not generate an AUTO_INCREMENT value. If you need to save the value for later, be sure to call this immediately after the query that generates the value. The ID is updated after INSERT and UPDATE statements that generate an AUTO_INCREMENT value or that set a column value to LAST_INSERT_ID(expr). See section 6.3.5.2 Miscellaneous Functions in the MySQL documentation. 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 queries because the value of that function is maintained in the server. |
kill(...)Asks the server to kill the thread specified by pid. Non-standard. |
next_result(...)If more query results exist, next_result() reads the next query results and returns the status back to application. After calling next_result() the state of the connection is as if you had called query() for the next query. This means that you can now call store_result(), warning_count(), affected_rows() , and so forth. Returns 0 if there are more results; -1 if there are no more results Non-standard. |
ping(...)Checks whether or not the connection to the server is working. If it has gone down, an automatic reconnection is attempted. This function can be used by clients that remain idle for a long while, to check whether or not the server has closed the connection and reconnect if necessary. New in 1.2.2: Accepts an optional reconnect parameter. If True, then the client will attempt reconnection. Note that this setting is persistent. By default, this is on in MySQL<5.0.3, and off thereafter. Non-standard. You should assume that ping() performs an implicit rollback; use only when starting a new transaction. You have been warned. |
query(...)Execute a query. store_result() or use_result() will get the result set, if any. Non-standard. Use cursor() to create a cursor, then cursor.execute(). |
rollback(...)Rolls backs the current transaction |
select_db(...)Causes the database specified by db to become the default (current) database on the connection specified by mysql. In subsequent queries, this database is the default for table references that do not include an explicit database specifier. Fails unless the connected user can be authenticated as having permission to use the database. Non-standard. |
set_character_set(...)Sets the default character set for the current connection. Non-standard. |
set_server_option(option)for the connection. Non-standard. |
shutdown(...)Asks the database server to shut down. The connected user must have shutdown privileges. Non-standard. |
sqlstate(...)Returns a string containing the SQLSTATE error code for the last error. The error code consists of five characters. '00000' means "no error." The values are specified by ANSI SQL and ODBC. For a list of possible values, see section 23 Error Handling in MySQL in the MySQL Manual. Note that not all MySQL errors are yet mapped to SQLSTATE's. The value 'HY000' (general error) is used for unmapped errors. Non-standard. |
stat(...)Returns a character string containing information similar to that provided by the mysqladmin status command. This includes uptime in seconds and the number of running threads, questions, reloads, and open tables. Non-standard. |
store_result(...)Returns a result object acquired by mysql_store_result (results stored in the client). If no results are available, None is returned. Non-standard. |
string_literal(obj)This means, any special SQL characters are escaped, and it is enclosed within single quotes. In other words, it performs: "'%s'" % escape_string(str(obj)) Use connection.string_literal(obj), if you use it at all. _mysql.string_literal(obj) cannot handle character sets. |
thread_id(...)Returns the thread ID of the current connection. This value can be used as an argument to kill() to kill the thread. If the connection is lost and you reconnect with ping(), the thread ID will change. This means you should not get the thread ID and store it for later. You should get it when you need it. Non-standard. |
use_result(...)Returns a result object acquired by mysql_use_result (results stored in the server). If no results are available, None is returned. Non-standard. |
warning_count(...)Returns the number of warnings generated during execution of the previous SQL statement. Non-standard. |
Class Variable Details |
---|
client_flag
|
converter
|
open
|
port
|
server_capabilities
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Sat Mar 3 21:14:16 2007 | http://epydoc.sf.net |