Skip to content

Commit b372acc

Browse files
committed
MySQL for Python
0 parents  commit b372acc

37 files changed

+8267
-0
lines changed

HISTORY

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
=====================
2+
What's new in 1.2.3
3+
=====================
4+
5+
ez_setup.py has been update to include various fixes that affect the build.
6+
7+
Better Python version and dependency detection as well as eliminate exception
8+
warnings under Python 2.6.
9+
10+
Eliminated memory leaks related to Unicode and failed connections.
11+
12+
Corrected connection .escape() functionality.
13+
14+
Miscellaneous cleanups and and expanded testing suite to ensure ongoing release
15+
quality.
16+
17+
=====================
18+
What's new in 1.2.2
19+
=====================
20+
21+
The build system has been completely redone and should now build
22+
on Windows without any patching; uses setuptools.
23+
24+
Added compatibility for Python 2.5, including support for with statement.
25+
26+
connection.ping() now takes an optional boolean argument which can
27+
enable (or disable) automatic reconnection.
28+
29+
Support returning SET columns as Python sets was removed due to an
30+
API bug in MySQL; corresponding test removed.
31+
32+
Added a test for single-character CHAR columns.
33+
34+
BLOB columns are now returned as Python strings instead of byte arrays.
35+
36+
BINARY character columns are always returned as Python strings, and not
37+
unicode.
38+
39+
Fixed a bug introduced in 1.2.1 where the new SHOW WARNINGS support broke
40+
SSCursor.
41+
42+
Only encode the query (convert to a string) when it is a unicode instance;
43+
re-encoding encoded strings would break things.
44+
45+
Make a deep copy of conv when connecting, since it can be modified.
46+
47+
Added support for new VARCHAR and BIT column types.
48+
49+
DBAPISet objects were broken, but nobody noticed.
50+
51+
52+
========================
53+
What's new in 1.2.1_p2
54+
========================
55+
56+
There are some minor build fixes which probably only affect MySQL
57+
older than 4.0.
58+
59+
If you had MySQL older than 4.1, the new charset and sql_mode
60+
parameters didn't work right. In fact, it was impossible to create
61+
a connection due to the charset problem.
62+
63+
If you are using MySQL-4.1 or newer, there is no practical difference
64+
between 1.2.1 and 1.2.1_p2, and you don't need to upgrade.
65+
66+
67+
=====================
68+
What's new in 1.2.1
69+
=====================
70+
71+
Switched to Subversion. Was going to do this for 1.3, but a
72+
SourceForge CVS outage has forced the issue.
73+
74+
Mapped a lot of new 4.1 and 5.0 error codes to Python exceptions
75+
76+
Added an API call for mysql_set_character_set(charset) (MySQL > 5.0.7)
77+
78+
Added an API call for mysql_get_character_set_info() (MySQL > 5.0.10)
79+
80+
Revamped the build system. Edit site.cfg if necessary (probably not
81+
in most cases)
82+
83+
Python-2.3 is now the minimum version.
84+
85+
Dropped support for mx.Datetime and stringtimes; always uses Python
86+
datetime module now.
87+
88+
Improved unit tests
89+
90+
New connect() options:
91+
* charset: sets character set, implies use_unicode
92+
* sql_mode: sets SQL mode (i.e. ANSI, etc.; see MySQL docs)
93+
94+
When using MySQL-4.1 or newer, enables MULTI_STATEMENTS
95+
96+
When using MySQL-5.0 or newer, enables MULTI_RESULTS
97+
98+
When using MySQL-4.1 or newer, more detailed warning messages
99+
are produced
100+
101+
SET columns returned as Python Set types; you can pass a Set as
102+
a parameter to cursor.execute().
103+
104+
Support for the new MySQL-5.0 DECIMAL implementation
105+
106+
Support for Python Decimal type
107+
108+
Some use of weak references internally. Cursors no longer leak
109+
if you don't close them. Connections still do, unfortunately.
110+
111+
ursor.fetchXXXDict() methods raise DeprecationWarning
112+
113+
cursor.begin() is making a brief reappearence.
114+
115+
cursor.callproc() now works, with some limitations.
116+

MANIFEST.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
recursive-include doc *.txt
2+
recursive-include tests *.py
3+
include MANIFEST.in
4+
include MANIFEST
5+
include ChangeLog
6+
include HISTORY
7+
include GPL
8+
include pymemcompat.h
9+
include metadata.cfg
10+
include site.cfg
11+
include setup_common.py
12+
include setup_posix.py
13+
include setup_windows.py

MySQL_python.egg-info/SOURCES.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.cvsignore
2+
HISTORY
3+
MANIFEST.in
4+
README
5+
_mysql.c
6+
_mysql_exceptions.py
7+
ez_setup.py
8+
metadata.cfg
9+
pymemcompat.h
10+
setup.cfg
11+
setup.py
12+
setup_common.py
13+
setup_posix.py
14+
setup_windows.py
15+
site.cfg
16+
MySQL_python.egg-info/PKG-INFO
17+
MySQL_python.egg-info/SOURCES.txt
18+
MySQL_python.egg-info/dependency_links.txt
19+
MySQL_python.egg-info/top_level.txt
20+
MySQLdb/.cvsignore
21+
MySQLdb/__init__.py
22+
MySQLdb/connections.py
23+
MySQLdb/converters.py
24+
MySQLdb/cursors.py
25+
MySQLdb/release.py
26+
MySQLdb/times.py
27+
MySQLdb/constants/.cvsignore
28+
MySQLdb/constants/CLIENT.py
29+
MySQLdb/constants/CR.py
30+
MySQLdb/constants/ER.py
31+
MySQLdb/constants/FIELD_TYPE.py
32+
MySQLdb/constants/FLAG.py
33+
MySQLdb/constants/REFRESH.py
34+
MySQLdb/constants/__init__.py
35+
doc/.cvsignore
36+
doc/FAQ.txt
37+
doc/MySQLdb.txt
38+
tests/capabilities.py
39+
tests/dbapi20.py
40+
tests/test_MySQLdb_capabilities.py
41+
tests/test_MySQLdb_dbapi20.py
42+
tests/test_MySQLdb_nonstandard.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

MySQL_python.egg-info/top_level.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_mysql
2+
MySQLdb
3+
_mysql_exceptions

MySQLdb/__init__.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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: 603 $"""[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+
try:
35+
frozenset
36+
except NameError:
37+
from sets import ImmutableSet as frozenset
38+
39+
class DBAPISet(frozenset):
40+
41+
"""A special type of set for which A == x is true if A is a
42+
DBAPISet and x is a member of that set."""
43+
44+
def __eq__(self, other):
45+
if isinstance(other, DBAPISet):
46+
return not self.difference(other)
47+
return other in self
48+
49+
50+
STRING = DBAPISet([FIELD_TYPE.ENUM, FIELD_TYPE.STRING,
51+
FIELD_TYPE.VAR_STRING])
52+
BINARY = DBAPISet([FIELD_TYPE.BLOB, FIELD_TYPE.LONG_BLOB,
53+
FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.TINY_BLOB])
54+
NUMBER = DBAPISet([FIELD_TYPE.DECIMAL, FIELD_TYPE.DOUBLE, FIELD_TYPE.FLOAT,
55+
FIELD_TYPE.INT24, FIELD_TYPE.LONG, FIELD_TYPE.LONGLONG,
56+
FIELD_TYPE.TINY, FIELD_TYPE.YEAR])
57+
DATE = DBAPISet([FIELD_TYPE.DATE, FIELD_TYPE.NEWDATE])
58+
TIME = DBAPISet([FIELD_TYPE.TIME])
59+
TIMESTAMP = DBAPISet([FIELD_TYPE.TIMESTAMP, FIELD_TYPE.DATETIME])
60+
DATETIME = TIMESTAMP
61+
ROWID = DBAPISet()
62+
63+
def test_DBAPISet_set_equality():
64+
assert STRING == STRING
65+
66+
def test_DBAPISet_set_inequality():
67+
assert STRING != NUMBER
68+
69+
def test_DBAPISet_set_equality_membership():
70+
assert FIELD_TYPE.VAR_STRING == STRING
71+
72+
def test_DBAPISet_set_inequality_membership():
73+
assert FIELD_TYPE.DATE != STRING
74+
75+
def Binary(x):
76+
return str(x)
77+
78+
def Connect(*args, **kwargs):
79+
"""Factory function for connections.Connection."""
80+
from connections import Connection
81+
return Connection(*args, **kwargs)
82+
83+
connect = Connection = Connect
84+
85+
__all__ = [ 'BINARY', 'Binary', 'Connect', 'Connection', 'DATE',
86+
'Date', 'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks',
87+
'TimestampFromTicks', 'DataError', 'DatabaseError', 'Error',
88+
'FIELD_TYPE', 'IntegrityError', 'InterfaceError', 'InternalError',
89+
'MySQLError', 'NULL', 'NUMBER', 'NotSupportedError', 'DBAPISet',
90+
'OperationalError', 'ProgrammingError', 'ROWID', 'STRING', 'TIME',
91+
'TIMESTAMP', 'Warning', 'apilevel', 'connect', 'connections',
92+
'constants', 'converters', 'cursors', 'debug', 'escape', 'escape_dict',
93+
'escape_sequence', 'escape_string', 'get_client_info',
94+
'paramstyle', 'string_literal', 'threadsafety', 'version_info']
95+
96+
97+
98+

0 commit comments

Comments
 (0)