annotate MySQLdb/__init__.py @ 54:6e31278d3433 MySQLdb

There's no good reason to delay imports when the module is (1) useless without it or (2) you do the same late import more than once.
author kylev
date Mon, 23 Feb 2009 23:52:44 +0000
parents 6122b2cacd20
children 228a45771d14
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
1 """
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
2 MySQLdb
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
3 =======
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
4 A DB API v2.0 compatible interface to MySQL
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
5 -------------------------------------------
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
6
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
7 This package is a wrapper around _mysql, which mostly implements the
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
8 MySQL C API.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
9
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
10 See the C API specification and the MySQL documentation for more info
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
11 on other items.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
12
15
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
13 For information on the DB API, see PEP-249.
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
14
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
15 For information on how MySQLdb handles type conversion, see the
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
16 MySQLdb.converters module.
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
17 """
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
18
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
19 __revision__ = """$Revision$"""[11:-2]
10
3f4c6af70e52 Me and PyLint had a knife fight, but PyLint had a gun.
adustman
parents: 4
diff changeset
20 from MySQLdb.release import __version__, version_info, __author__
18
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
21 from MySQLdb.exceptions import Warning, Error, InterfaceError, DataError, \
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
22 DatabaseError, OperationalError, IntegrityError, InternalError, \
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
23 NotSupportedError, ProgrammingError
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
24
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
25 threadsafety = 1
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
26 apilevel = "2.0"
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
27 paramstyle = "format"
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
28
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
29 from MySQLdb.constants import FIELD_TYPE
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
30 from MySQLdb.times import Date, Time, Timestamp, \
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
31 DateFromTicks, TimeFromTicks, TimestampFromTicks
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
32
15
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
33
32
4a5668deee4a Merge back r554 for deprecated sets module
kylev
parents: 18
diff changeset
34 class DBAPISet(frozenset):
15
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
35 """A special type of set for which A == x is True if A is a
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
36 DBAPISet and x is a member of that set.
a275593a1630 More doc fixes
adustman
parents: 10
diff changeset
37 """
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
38 def __eq__(self, other):
32
4a5668deee4a Merge back r554 for deprecated sets module
kylev
parents: 18
diff changeset
39 if isinstance(other, DBAPISet):
4a5668deee4a Merge back r554 for deprecated sets module
kylev
parents: 18
diff changeset
40 return not self.difference(other)
4a5668deee4a Merge back r554 for deprecated sets module
kylev
parents: 18
diff changeset
41 return other in self
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
42
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
43
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
44 STRING = DBAPISet([FIELD_TYPE.ENUM, FIELD_TYPE.STRING,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
45 FIELD_TYPE.VAR_STRING])
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
46 BINARY = DBAPISet([FIELD_TYPE.BLOB, FIELD_TYPE.LONG_BLOB,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
47 FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.TINY_BLOB])
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
48 NUMBER = DBAPISet([FIELD_TYPE.DECIMAL, FIELD_TYPE.DOUBLE, FIELD_TYPE.FLOAT,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
49 FIELD_TYPE.INT24, FIELD_TYPE.LONG, FIELD_TYPE.LONGLONG,
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
50 FIELD_TYPE.TINY, FIELD_TYPE.YEAR])
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
51 DATE = DBAPISet([FIELD_TYPE.DATE, FIELD_TYPE.NEWDATE])
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
52 TIME = DBAPISet([FIELD_TYPE.TIME])
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
53 TIMESTAMP = DBAPISet([FIELD_TYPE.TIMESTAMP, FIELD_TYPE.DATETIME])
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
54 DATETIME = TIMESTAMP
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
55 ROWID = DBAPISet()
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
56
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
57 def Binary(x):
10
3f4c6af70e52 Me and PyLint had a knife fight, but PyLint had a gun.
adustman
parents: 4
diff changeset
58 """Return x as a binary type."""
4
b5a377255eea Merge changes from MySQLdb-1.2 branch (448-455)
adustman
parents: 0
diff changeset
59 return str(x)
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
60
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
61 def Connect(*args, **kwargs):
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
62 """Factory function for connections.Connection."""
10
3f4c6af70e52 Me and PyLint had a knife fight, but PyLint had a gun.
adustman
parents: 4
diff changeset
63 from MySQLdb.connections import Connection
0
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
64 return Connection(*args, **kwargs)
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
65
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
66 connect = Connection = Connect
e48810735f11 Copying 1.2.1 to be the new trunk
adustman
parents:
diff changeset
67
18
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
68 __all__ = [
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
69 'BINARY', 'Binary', 'Connect', 'Connection', 'DATE', 'Date',
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
70 'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks', 'TimestampFromTicks',
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
71 'DataError', 'DatabaseError', 'Error', 'FIELD_TYPE', 'IntegrityError',
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
72 'InterfaceError', 'InternalError', 'MySQLError', 'NULL', 'NUMBER',
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
73 'NotSupportedError', 'DBAPISet', 'OperationalError', 'ProgrammingError',
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
74 'ROWID', 'STRING', 'TIME', 'TIMESTAMP', 'Warning', 'apilevel', 'connect',
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
75 'connections', 'constants', 'converters', 'cursors', 'debug', 'escape',
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
76 'escape_dict', 'escape_sequence', 'escape_string', 'get_client_info',
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
77 'paramstyle', 'string_literal', 'threadsafety', 'version_info',
d55bfb1a4701 Tons of changes from major refactoring/cleanup. This is all really broken
adustman
parents: 15
diff changeset
78 ]