Mercurial > p > mysql-python > mysqldb-2
comparison MySQLdb/__init__.py @ 0:e48810735f11 MySQLdb
Copying 1.2.1 to be the new trunk
author | adustman |
---|---|
date | Sun, 02 Apr 2006 18:20:53 +0000 |
parents | |
children | b5a377255eea |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e48810735f11 |
---|---|
1 """MySQLdb - A DB API v2.0 compatible interface to MySQL. | |
2 | |
3 This package is a wrapper around _mysql, which mostly implements the | |
4 MySQL C API. | |
5 | |
6 connect() -- connects to server | |
7 | |
8 See the C API specification and the MySQL documentation for more info | |
9 on other items. | |
10 | |
11 For information on how MySQLdb handles type conversion, see the | |
12 MySQLdb.converters module. | |
13 | |
14 """ | |
15 | |
16 __revision__ = """$Revision$"""[11:-2] | |
17 from release import __version__, version_info, __author__ | |
18 | |
19 import _mysql | |
20 | |
21 if version_info != _mysql.version_info: | |
22 raise ImportError, "this is MySQLdb version %s, but _mysql is version %r" %\ | |
23 (version_info, _mysql.version_info) | |
24 | |
25 threadsafety = 1 | |
26 apilevel = "2.0" | |
27 paramstyle = "format" | |
28 | |
29 from _mysql import * | |
30 from MySQLdb.constants import FIELD_TYPE | |
31 from MySQLdb.times import Date, Time, Timestamp, \ | |
32 DateFromTicks, TimeFromTicks, TimestampFromTicks | |
33 | |
34 from sets import ImmutableSet | |
35 class DBAPISet(ImmutableSet): | |
36 | |
37 """A special type of set for which A == x is true if A is a | |
38 DBAPISet and x is a member of that set.""" | |
39 | |
40 def __ne__(self, other): | |
41 from sets import BaseSet | |
42 if isinstance(other, BaseSet): | |
43 return super(self).__ne__(self, other) | |
44 else: | |
45 return other not in self | |
46 | |
47 def __eq__(self, other): | |
48 from sets import BaseSet | |
49 if isinstance(other, BaseSet): | |
50 return super(self).__eq__(self, other) | |
51 else: | |
52 return other in self | |
53 | |
54 | |
55 STRING = DBAPISet([FIELD_TYPE.ENUM, FIELD_TYPE.STRING, | |
56 FIELD_TYPE.VAR_STRING]) | |
57 BINARY = DBAPISet([FIELD_TYPE.BLOB, FIELD_TYPE.LONG_BLOB, | |
58 FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.TINY_BLOB]) | |
59 NUMBER = DBAPISet([FIELD_TYPE.DECIMAL, FIELD_TYPE.DOUBLE, FIELD_TYPE.FLOAT, | |
60 FIELD_TYPE.INT24, FIELD_TYPE.LONG, FIELD_TYPE.LONGLONG, | |
61 FIELD_TYPE.TINY, FIELD_TYPE.YEAR]) | |
62 DATE = DBAPISet([FIELD_TYPE.DATE, FIELD_TYPE.NEWDATE]) | |
63 TIME = DBAPISet([FIELD_TYPE.TIME]) | |
64 TIMESTAMP = DBAPISet([FIELD_TYPE.TIMESTAMP, FIELD_TYPE.DATETIME]) | |
65 DATETIME = TIMESTAMP | |
66 ROWID = DBAPISet() | |
67 | |
68 def Binary(x): | |
69 from array import array | |
70 return array('c', x) | |
71 | |
72 def Connect(*args, **kwargs): | |
73 """Factory function for connections.Connection.""" | |
74 from connections import Connection | |
75 return Connection(*args, **kwargs) | |
76 | |
77 connect = Connection = Connect | |
78 | |
79 __all__ = [ 'BINARY', 'Binary', 'Connect', 'Connection', 'DATE', | |
80 'Date', 'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks', | |
81 'TimestampFromTicks', 'DataError', 'DatabaseError', 'Error', | |
82 'FIELD_TYPE', 'IntegrityError', 'InterfaceError', 'InternalError', | |
83 'MySQLError', 'NULL', 'NUMBER', 'NotSupportedError', 'DBAPISet', | |
84 'OperationalError', 'ProgrammingError', 'ROWID', 'STRING', 'TIME', | |
85 'TIMESTAMP', 'Warning', 'apilevel', 'connect', 'connections', | |
86 'constants', 'cursors', 'debug', 'escape', 'escape_dict', | |
87 'escape_sequence', 'escape_string', 'get_client_info', | |
88 'paramstyle', 'string_literal', 'threadsafety', 'version_info'] | |
89 | |
90 | |
91 | |
92 |