diff --git a/MySQLdb/doc/MySQLdb.sgml b/MySQLdb/doc/MySQLdb.sgml index e6d2796..7cd2bd1 100644 --- a/MySQLdb/doc/MySQLdb.sgml +++ b/MySQLdb/doc/MySQLdb.sgml @@ -41,7 +41,7 @@ cannot help you with compiling and running under Windows. MySQLdb requires Python 1.5.2 or newer. Earlier versions will not work, because support for C MySQL @@ -61,16 +61,22 @@ avoid this problem, use the MySQL-3.23

-MySQL-3.23 is now stable (3.23.37 as of this writing). MySQLdb +MySQL-3.23 is now stable (3.23.51 as of this writing). MySQLdb supports transactions if the DateTime

If you have the MySQL-4.0 +

+MySQL-4.0 is supported, though still alpha. + + +DateTime +

If you have the package installed (recommended), MySQLdb will use it for date-related objects. Otherwise, these will be returned to @@ -153,6 +159,10 @@ the mysql_ prefix is dropped from the name. Most of the conn methods listed are also available as MySQLdb Connection object methods. Their use is non-portable. +

+Starting with MySQLdb-0.9.2, the connection and result objects are +subclassable types if you have at least Python-2.2. + C API | _mysql @@ -184,6 +194,7 @@ object methods. Their use is non-portable. @ mysql_stat() | conn.stat() @ mysql_store_result() | conn.store_result() @ mysql_thread_id() | conn.thread_id() +@ mysql_thread_safe_client() | conn.thread_safe_client() @ mysql_use_result() | conn.use_result() @ CLIENT_* | MySQLdb.constants.CLIENT.* @ CR_* | MySQLdb.constants.CR.* @@ -263,7 +274,7 @@ db.query("""SELECT spam, eggs, sausage FROM breakfast There's no return value from this, but exceptions can be raised. The exceptions are defined in a separate module, to find out what they are, or you can use the catch-all unicode If set, CHAR and VARCHAR columns are returned + as Unicode strings, using the specified character set. + None means to use a default encoding. + apilevel @@ -448,6 +463,10 @@ or mine, and in the end, will probably hurt performance, since the MySQL the MySQL client library will probably upchuck and die. You have been warned. +

For threaded applications, try using a connection pool. + This can be done using the + . + paramstyle String constant stating the type of parameter marker formatting expected by the interface. Set to 'format' = ANSI C printf format codes, e.g. '...WHERE name=%s'. If a @@ -465,6 +484,9 @@ or mine, and in the end, will probably hurt performance, since the MySQL regardless of type. The interface performs all necessary quoting. + Note that any literal percent signs in the query string passed + to execute() must be escaped, i.e. %%. + A dictionary mapping MySQL types (from FIELD_TYPE.*) to callable Python objects (usually functions) which convert from a string to the desired type; and @@ -486,7 +508,8 @@ This requires the string quoting function to be a method bound to the connection object. MySQLdb handles this for you automatically. However, if you feel the need to do something goofy with your strings, you will have to modify the dictionary after opening the connection. -In practice, you should never have to worry about this. +In practice, you should never have to worry about this. This also +applies to Unicode strings, if enabled. @@ -525,6 +548,10 @@ Compatibility note: The older defines this method, +

There are many more methods defined on the connection object which +are MySQL-specific. For more information on them, consult the internal +documentation using Cursor Objects

@@ -553,6 +580,13 @@ Compatibility note: The older defines this method, setoutputsizes() Does nothing, successfully. +nextset() + Advances the cursor to the next result set, discarding the remaining + rows in the current result set. If there are no additional result + sets, it returns None; otherwise it returns a true value. + + Note that MySQL presently doesn't support multiple result sets. + Some examples @@ -615,13 +649,14 @@ when there are no more rows to fetch.

The only other method you are very likely to use is when you have to do a multi-row insert: -c.execute("""INSERT INTO breakfast (name, spam, eggs, sausage, price) - VALUES (%s, %s, %s, %s, %s)""", - [ ("Spam and Sausage Lover's Plate", 5, 1, 8, 7.95 ), - ("Not So Much Spam Plate", 3, 2, 0, 3.95 ), - ("Don't Wany ANY SPAM! Plate", 0, 4, 3, 5.95 ) - ] - ) +c.executemany( + """INSERT INTO breakfast (name, spam, eggs, sausage, price) + VALUES (%s, %s, %s, %s, %s)""", + [ + ("Spam and Sausage Lover's Plate", 5, 1, 8, 7.95 ), + ("Not So Much Spam Plate", 3, 2, 0, 3.95 ), + ("Don't Wany ANY SPAM! Plate", 0, 4, 3, 5.95 ) + ] ) Here we are inserting three rows of five values. Notice that there is a mix of types (strings, ints, floats) though we still only use @@ -702,7 +737,7 @@ Use only if you are dealing with potentially large result sets. Cursors with the "NW" suffix do not raise Warnings. +

For an example of how to use these classes,