Package MySQLdb
[hide private]
[frames] | no frames]

Package MySQLdb

source code

MySQLdb - A DB API v2.0 compatible interface to MySQL.

This package is a wrapper around _mysql, which mostly implements the MySQL C API.

connect() -- connects to server

See the C API specification and the MySQL documentation for more info on other items.

For information on how MySQLdb handles type conversion, see the MySQLdb.converters module.


Version: 1.2.2

Author: Andy Dustman <adustman@users.sourceforge.net>

Submodules [hide private]

Classes [hide private]
  Date
date(year, month, day) --> date object
  Time
time([hour[, minute[, second[, microsecond[, tzinfo]]]]]) --> a time object
  Timestamp
datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
  DBAPISet
A special type of set for which A == x is true if A is a DBAPISet and x is a member of that set.
  DataError
Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range, etc.
  DatabaseError
Exception raised for errors that are related to the database.
  Error
Exception that is the base class of all other error exceptions (not Warning).
  IntegrityError
Exception raised when the relational integrity of the database is affected, e.g.
  InterfaceError
Exception raised for errors that are related to the database interface rather than the database itself.
  InternalError
Exception raised when the database encounters an internal error, e.g.
  MySQLError
Exception related to operation with MySQL.
  NotSupportedError
Exception raised in case a method or database API was used which is not supported by the database, e.g.
  OperationalError
Exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer, e.g.
  ProgrammingError
Exception raised for programming errors, e.g.
  Warning
Exception raised for important warnings like data truncations while inserting, etc.
Functions [hide private]
 
DateFromTicks(ticks)
Convert UNIX ticks into a date instance.
source code
 
TimeFromTicks(ticks)
Convert UNIX ticks into a time instance.
source code
 
TimestampFromTicks(ticks)
Convert UNIX ticks into a datetime instance.
source code
 
Binary(x) source code
 
Connect(*args, **kwargs)
Factory function for connections.Connection.
source code
 
Connection(*args, **kwargs)
Factory function for connections.Connection.
source code
 
connect(*args, **kwargs)
Factory function for connections.Connection.
source code
 
debug(...)
Does a DBUG_PUSH with the given string.
 
escape(obj, dict)
escape any special characters in object obj using mapping dict to provide quoting functions for each type.
 
escape_dict(d, dict)
escape any special characters in dictionary d using mapping dict to provide quoting functions for each type.
 
escape_sequence(seq, dict)
escape any special characters in sequence seq using mapping dict to provide quoting functions for each type.
 
escape_string(s)
quote any SQL-interpreted characters in string s.
 
get_client_info()
Returns a string that represents the client library version.
 
string_literal(obj)
converts object obj into a SQL string literal.
Variables [hide private]
  __revision__ = '491'
  version_info = (1, 2, 2, 'final', 0)
  threadsafety = 1
  apilevel = '2.0'
  paramstyle = 'format'
  STRING = DBAPISet([253, 254, 247])
  BINARY = DBAPISet([249, 250, 251, 252])
  NUMBER = DBAPISet([0, 1, 3, 4, 5, 8, 9, 13])
  DATE = DBAPISet([10, 14])
  TIME = DBAPISet([11])
  TIMESTAMP = DBAPISet([12, 7])
  DATETIME = DBAPISet([12, 7])
  ROWID = DBAPISet([])
  NULL = 'NULL'
Function Details [hide private]

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)

 
escape any special characters in object obj using mapping dict to provide quoting functions for each type. Returns a SQL literal string.

escape_dict(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)

 
escape any special characters in sequence seq using mapping dict to provide quoting functions for each type. Returns a tuple of escaped items.

escape_string(s)

 

quote any SQL-interpreted characters in 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.

string_literal(obj)

 

converts object obj into a SQL string literal. 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.