Module _mysql
[show private | hide private]
[frames | no frames]

Module _mysql

an adaptation of the MySQL C API (mostly)

You probably are better off using MySQLdb instead of using this module directly.

In general, renaming goes from mysql_* to _mysql.*. _mysql.connect() returns a connection object (MYSQL). Functions which expect MYSQL * as an argument are now methods of the connection object. A number of things return result objects (MYSQL_RES). Functions which expect MYSQL_RES * as an argument are now methods of the result object. Deprecated functions (as of 3.23) are NOT implemented.


Classes
connection Returns a MYSQL connection object.
result result(connection, use=0, converter={}) -- Result set from a query.

Function Summary
  connect(...)
Returns a MYSQL connection object.
  debug(...)
Does a DBUG_PUSH with the given string.
  escape(obj, dict)
using mapping dict to provide quoting functions for each type.
  escape_dict(...)
escape_sequence(d, dict) -- escape any special characters in dictionary d using mapping dict to provide quoting functions for each type.
  escape_sequence(seq, dict)
seq using mapping dict to provide quoting functions for each type.
  escape_string(s)
Use connection.escape_string(s), if you use it at all.
  get_client_info()
the client library version.
  server_end(...)
Shut down embedded server.
  server_init(...)
Initialize embedded server.
  string_literal(obj)
This means, any special SQL characters are escaped, and it is enclosed within single quotes.
  thread_safe(...)
Indicates whether the client is compiled as thread-safe.

Variable Summary
str __version__ = '1.2.2c1'
dict __warningregistry__ = {('Module _mysql was already impor...
str NULL = 'NULL'
tuple version_info = (1, 2, 2, 'gamma', 1)

Function Details

connect(...)

Returns a MYSQL connection object. Exclusive use of keyword parameters strongly recommended. Consult the MySQL C API documentation for more details.

host
string, host to connect
user
string, user to connect as
passwd
string, password to use
db
string, database to use
port
integer, TCP/IP port to connect to
unix_socket
string, location of unix_socket (UNIX-ish only)
conv
mapping, maps MySQL FIELD_TYPE.* to Python functions which convert a string to the appropriate Python type
connect_timeout
number of seconds to wait before the connection attempt fails.
compress
if set, gzip compression is enabled
named_pipe
if set, connect to server via named pipe (Windows only)
init_command
command which is run once the connection is created
read_default_file
see the MySQL documentation for mysql_options()
read_default_group
see the MySQL documentation for mysql_options()
client_flag
client flags from MySQLdb.constants.CLIENT
load_infile
int, non-zero enables LOAD LOCAL INFILE, zero disables

debug(...)

Does a DBUG_PUSH with the given string. mysql_debug() uses the Fred Fish debug library. To use this function, you must compile the client library to support debugging.

escape(obj, dict)

using mapping dict to provide quoting functions for each type. Returns a SQL literal string.

escape_dict(...)

escape_sequence(d, dict) -- escape any special characters in dictionary d using mapping dict to provide quoting functions for each type. Returns a dictionary of escaped items.

escape_sequence(seq, dict)

seq using mapping dict to provide quoting functions for each type. Returns a tuple of escaped items.

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.

get_client_info()

the client library version.

server_end(...)

Shut down embedded server. If not using an embedded server, this does nothing.

server_init(...)

Initialize embedded server. If this client is not linked against the embedded server library, this function does nothing.

args -- sequence of command-line arguments groups -- sequence of groups to use in defaults files

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_safe(...)

Indicates whether the client is compiled as thread-safe.


Variable Details

__version__

Type:
str
Value:
'1.2.2c1'                                                              

__warningregistry__

Type:
dict
Value:
{('Module _mysql was already imported from /usr/lib/python2.4/site-pac\
kages/MySQL_python-1.2.2c1-py2.4-linux-i686.egg/_mysql.pyc, but /home/\
andy/devel/MySQLdb-1.2 is being added to sys.path', <class exceptions.\
UserWarning at 0xb7e1ae6c>, 3): 1}                                     

NULL

Type:
str
Value:
'NULL'                                                                 

version_info

Type:
tuple
Value:
(1, 2, 2, 'gamma', 1)                                                  

Generated by Epydoc 2.1 on Sat Mar 3 21:14:16 2007 http://epydoc.sf.net