mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2026-03-13 08:00:02 +08:00
Revert "Hopefully this is just a very minor spacing cleanup."
This reverts commit cdc221a807.
Conflicts:
MySQLdb/MANIFEST.in
MySQLdb/metadata.cfg
This commit is contained in:
232
MySQLdb/HISTORY
232
MySQLdb/HISTORY
@@ -1,116 +1,116 @@
|
||||
=====================
|
||||
What's new in 1.2.3
|
||||
=====================
|
||||
|
||||
ez_setup.py has been update to include various fixes that affect the build.
|
||||
|
||||
Better Python version and dependency detection as well as eliminate exception
|
||||
warnings under Python 2.6.
|
||||
|
||||
Eliminated memory leaks related to Unicode and failed connections.
|
||||
|
||||
Corrected connection .escape() functionality.
|
||||
|
||||
Miscellaneous cleanups and and expanded testing suite to ensure ongoing release
|
||||
quality.
|
||||
|
||||
=====================
|
||||
What's new in 1.2.2
|
||||
=====================
|
||||
|
||||
The build system has been completely redone and should now build
|
||||
on Windows without any patching; uses setuptools.
|
||||
|
||||
Added compatibility for Python 2.5, including support for with statement.
|
||||
|
||||
connection.ping() now takes an optional boolean argument which can
|
||||
enable (or disable) automatic reconnection.
|
||||
|
||||
Support returning SET columns as Python sets was removed due to an
|
||||
API bug in MySQL; corresponding test removed.
|
||||
|
||||
Added a test for single-character CHAR columns.
|
||||
|
||||
BLOB columns are now returned as Python strings instead of byte arrays.
|
||||
|
||||
BINARY character columns are always returned as Python strings, and not
|
||||
unicode.
|
||||
|
||||
Fixed a bug introduced in 1.2.1 where the new SHOW WARNINGS support broke
|
||||
SSCursor.
|
||||
|
||||
Only encode the query (convert to a string) when it is a unicode instance;
|
||||
re-encoding encoded strings would break things.
|
||||
|
||||
Make a deep copy of conv when connecting, since it can be modified.
|
||||
|
||||
Added support for new VARCHAR and BIT column types.
|
||||
|
||||
DBAPISet objects were broken, but nobody noticed.
|
||||
|
||||
|
||||
========================
|
||||
What's new in 1.2.1_p2
|
||||
========================
|
||||
|
||||
There are some minor build fixes which probably only affect MySQL
|
||||
older than 4.0.
|
||||
|
||||
If you had MySQL older than 4.1, the new charset and sql_mode
|
||||
parameters didn't work right. In fact, it was impossible to create
|
||||
a connection due to the charset problem.
|
||||
|
||||
If you are using MySQL-4.1 or newer, there is no practical difference
|
||||
between 1.2.1 and 1.2.1_p2, and you don't need to upgrade.
|
||||
|
||||
|
||||
=====================
|
||||
What's new in 1.2.1
|
||||
=====================
|
||||
|
||||
Switched to Subversion. Was going to do this for 1.3, but a
|
||||
SourceForge CVS outage has forced the issue.
|
||||
|
||||
Mapped a lot of new 4.1 and 5.0 error codes to Python exceptions
|
||||
|
||||
Added an API call for mysql_set_character_set(charset) (MySQL > 5.0.7)
|
||||
|
||||
Added an API call for mysql_get_character_set_info() (MySQL > 5.0.10)
|
||||
|
||||
Revamped the build system. Edit site.cfg if necessary (probably not
|
||||
in most cases)
|
||||
|
||||
Python-2.3 is now the minimum version.
|
||||
|
||||
Dropped support for mx.Datetime and stringtimes; always uses Python
|
||||
datetime module now.
|
||||
|
||||
Improved unit tests
|
||||
|
||||
New connect() options:
|
||||
* charset: sets character set, implies use_unicode
|
||||
* sql_mode: sets SQL mode (i.e. ANSI, etc.; see MySQL docs)
|
||||
|
||||
When using MySQL-4.1 or newer, enables MULTI_STATEMENTS
|
||||
|
||||
When using MySQL-5.0 or newer, enables MULTI_RESULTS
|
||||
|
||||
When using MySQL-4.1 or newer, more detailed warning messages
|
||||
are produced
|
||||
|
||||
SET columns returned as Python Set types; you can pass a Set as
|
||||
a parameter to cursor.execute().
|
||||
|
||||
Support for the new MySQL-5.0 DECIMAL implementation
|
||||
|
||||
Support for Python Decimal type
|
||||
|
||||
Some use of weak references internally. Cursors no longer leak
|
||||
if you don't close them. Connections still do, unfortunately.
|
||||
|
||||
ursor.fetchXXXDict() methods raise DeprecationWarning
|
||||
|
||||
cursor.begin() is making a brief reappearence.
|
||||
|
||||
cursor.callproc() now works, with some limitations.
|
||||
|
||||
=====================
|
||||
What's new in 1.2.3
|
||||
=====================
|
||||
|
||||
ez_setup.py has been update to include various fixes that affect the build.
|
||||
|
||||
Better Python version and dependency detection as well as eliminate exception
|
||||
warnings under Python 2.6.
|
||||
|
||||
Eliminated memory leaks related to Unicode and failed connections.
|
||||
|
||||
Corrected connection .escape() functionality.
|
||||
|
||||
Miscellaneous cleanups and and expanded testing suite to ensure ongoing release
|
||||
quality.
|
||||
|
||||
=====================
|
||||
What's new in 1.2.2
|
||||
=====================
|
||||
|
||||
The build system has been completely redone and should now build
|
||||
on Windows without any patching; uses setuptools.
|
||||
|
||||
Added compatibility for Python 2.5, including support for with statement.
|
||||
|
||||
connection.ping() now takes an optional boolean argument which can
|
||||
enable (or disable) automatic reconnection.
|
||||
|
||||
Support returning SET columns as Python sets was removed due to an
|
||||
API bug in MySQL; corresponding test removed.
|
||||
|
||||
Added a test for single-character CHAR columns.
|
||||
|
||||
BLOB columns are now returned as Python strings instead of byte arrays.
|
||||
|
||||
BINARY character columns are always returned as Python strings, and not
|
||||
unicode.
|
||||
|
||||
Fixed a bug introduced in 1.2.1 where the new SHOW WARNINGS support broke
|
||||
SSCursor.
|
||||
|
||||
Only encode the query (convert to a string) when it is a unicode instance;
|
||||
re-encoding encoded strings would break things.
|
||||
|
||||
Make a deep copy of conv when connecting, since it can be modified.
|
||||
|
||||
Added support for new VARCHAR and BIT column types.
|
||||
|
||||
DBAPISet objects were broken, but nobody noticed.
|
||||
|
||||
|
||||
========================
|
||||
What's new in 1.2.1_p2
|
||||
========================
|
||||
|
||||
There are some minor build fixes which probably only affect MySQL
|
||||
older than 4.0.
|
||||
|
||||
If you had MySQL older than 4.1, the new charset and sql_mode
|
||||
parameters didn't work right. In fact, it was impossible to create
|
||||
a connection due to the charset problem.
|
||||
|
||||
If you are using MySQL-4.1 or newer, there is no practical difference
|
||||
between 1.2.1 and 1.2.1_p2, and you don't need to upgrade.
|
||||
|
||||
|
||||
=====================
|
||||
What's new in 1.2.1
|
||||
=====================
|
||||
|
||||
Switched to Subversion. Was going to do this for 1.3, but a
|
||||
SourceForge CVS outage has forced the issue.
|
||||
|
||||
Mapped a lot of new 4.1 and 5.0 error codes to Python exceptions
|
||||
|
||||
Added an API call for mysql_set_character_set(charset) (MySQL > 5.0.7)
|
||||
|
||||
Added an API call for mysql_get_character_set_info() (MySQL > 5.0.10)
|
||||
|
||||
Revamped the build system. Edit site.cfg if necessary (probably not
|
||||
in most cases)
|
||||
|
||||
Python-2.3 is now the minimum version.
|
||||
|
||||
Dropped support for mx.Datetime and stringtimes; always uses Python
|
||||
datetime module now.
|
||||
|
||||
Improved unit tests
|
||||
|
||||
New connect() options:
|
||||
* charset: sets character set, implies use_unicode
|
||||
* sql_mode: sets SQL mode (i.e. ANSI, etc.; see MySQL docs)
|
||||
|
||||
When using MySQL-4.1 or newer, enables MULTI_STATEMENTS
|
||||
|
||||
When using MySQL-5.0 or newer, enables MULTI_RESULTS
|
||||
|
||||
When using MySQL-4.1 or newer, more detailed warning messages
|
||||
are produced
|
||||
|
||||
SET columns returned as Python Set types; you can pass a Set as
|
||||
a parameter to cursor.execute().
|
||||
|
||||
Support for the new MySQL-5.0 DECIMAL implementation
|
||||
|
||||
Support for Python Decimal type
|
||||
|
||||
Some use of weak references internally. Cursors no longer leak
|
||||
if you don't close them. Connections still do, unfortunately.
|
||||
|
||||
ursor.fetchXXXDict() methods raise DeprecationWarning
|
||||
|
||||
cursor.begin() is making a brief reappearence.
|
||||
|
||||
cursor.callproc() now works, with some limitations.
|
||||
|
||||
|
||||
@@ -1,98 +1,98 @@
|
||||
"""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.
|
||||
|
||||
"""
|
||||
|
||||
__revision__ = """$Revision$"""[11:-2]
|
||||
from MySQLdb.release import __version__, version_info, __author__
|
||||
|
||||
import _mysql
|
||||
|
||||
if version_info != _mysql.version_info:
|
||||
raise ImportError("this is MySQLdb version %s, but _mysql is version %r" %
|
||||
(version_info, _mysql.version_info))
|
||||
|
||||
threadsafety = 1
|
||||
apilevel = "2.0"
|
||||
paramstyle = "format"
|
||||
|
||||
from _mysql import *
|
||||
from MySQLdb.constants import FIELD_TYPE
|
||||
from MySQLdb.times import Date, Time, Timestamp, \
|
||||
DateFromTicks, TimeFromTicks, TimestampFromTicks
|
||||
|
||||
try:
|
||||
frozenset
|
||||
except NameError:
|
||||
from sets import ImmutableSet as frozenset
|
||||
|
||||
class DBAPISet(frozenset):
|
||||
|
||||
"""A special type of set for which A == x is true if A is a
|
||||
DBAPISet and x is a member of that set."""
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, DBAPISet):
|
||||
return not self.difference(other)
|
||||
return other in self
|
||||
|
||||
|
||||
STRING = DBAPISet([FIELD_TYPE.ENUM, FIELD_TYPE.STRING,
|
||||
FIELD_TYPE.VAR_STRING])
|
||||
BINARY = DBAPISet([FIELD_TYPE.BLOB, FIELD_TYPE.LONG_BLOB,
|
||||
FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.TINY_BLOB])
|
||||
NUMBER = DBAPISet([FIELD_TYPE.DECIMAL, FIELD_TYPE.DOUBLE, FIELD_TYPE.FLOAT,
|
||||
FIELD_TYPE.INT24, FIELD_TYPE.LONG, FIELD_TYPE.LONGLONG,
|
||||
FIELD_TYPE.TINY, FIELD_TYPE.YEAR])
|
||||
DATE = DBAPISet([FIELD_TYPE.DATE, FIELD_TYPE.NEWDATE])
|
||||
TIME = DBAPISet([FIELD_TYPE.TIME])
|
||||
TIMESTAMP = DBAPISet([FIELD_TYPE.TIMESTAMP, FIELD_TYPE.DATETIME])
|
||||
DATETIME = TIMESTAMP
|
||||
ROWID = DBAPISet()
|
||||
|
||||
def test_DBAPISet_set_equality():
|
||||
assert STRING == STRING
|
||||
|
||||
def test_DBAPISet_set_inequality():
|
||||
assert STRING != NUMBER
|
||||
|
||||
def test_DBAPISet_set_equality_membership():
|
||||
assert FIELD_TYPE.VAR_STRING == STRING
|
||||
|
||||
def test_DBAPISet_set_inequality_membership():
|
||||
assert FIELD_TYPE.DATE != STRING
|
||||
|
||||
def Binary(x):
|
||||
return str(x)
|
||||
|
||||
def Connect(*args, **kwargs):
|
||||
"""Factory function for connections.Connection."""
|
||||
from MySQLdb.connections import Connection
|
||||
return Connection(*args, **kwargs)
|
||||
|
||||
connect = Connection = Connect
|
||||
|
||||
__all__ = [ 'BINARY', 'Binary', 'Connect', 'Connection', 'DATE',
|
||||
'Date', 'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks',
|
||||
'TimestampFromTicks', 'DataError', 'DatabaseError', 'Error',
|
||||
'FIELD_TYPE', 'IntegrityError', 'InterfaceError', 'InternalError',
|
||||
'MySQLError', 'NULL', 'NUMBER', 'NotSupportedError', 'DBAPISet',
|
||||
'OperationalError', 'ProgrammingError', 'ROWID', 'STRING', 'TIME',
|
||||
'TIMESTAMP', 'Warning', 'apilevel', 'connect', 'connections',
|
||||
'constants', 'converters', 'cursors', 'debug', 'escape', 'escape_dict',
|
||||
'escape_sequence', 'escape_string', 'get_client_info',
|
||||
'paramstyle', 'string_literal', 'threadsafety', 'version_info']
|
||||
|
||||
|
||||
|
||||
|
||||
"""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.
|
||||
|
||||
"""
|
||||
|
||||
__revision__ = """$Revision$"""[11:-2]
|
||||
from MySQLdb.release import __version__, version_info, __author__
|
||||
|
||||
import _mysql
|
||||
|
||||
if version_info != _mysql.version_info:
|
||||
raise ImportError("this is MySQLdb version %s, but _mysql is version %r" %
|
||||
(version_info, _mysql.version_info))
|
||||
|
||||
threadsafety = 1
|
||||
apilevel = "2.0"
|
||||
paramstyle = "format"
|
||||
|
||||
from _mysql import *
|
||||
from MySQLdb.constants import FIELD_TYPE
|
||||
from MySQLdb.times import Date, Time, Timestamp, \
|
||||
DateFromTicks, TimeFromTicks, TimestampFromTicks
|
||||
|
||||
try:
|
||||
frozenset
|
||||
except NameError:
|
||||
from sets import ImmutableSet as frozenset
|
||||
|
||||
class DBAPISet(frozenset):
|
||||
|
||||
"""A special type of set for which A == x is true if A is a
|
||||
DBAPISet and x is a member of that set."""
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, DBAPISet):
|
||||
return not self.difference(other)
|
||||
return other in self
|
||||
|
||||
|
||||
STRING = DBAPISet([FIELD_TYPE.ENUM, FIELD_TYPE.STRING,
|
||||
FIELD_TYPE.VAR_STRING])
|
||||
BINARY = DBAPISet([FIELD_TYPE.BLOB, FIELD_TYPE.LONG_BLOB,
|
||||
FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.TINY_BLOB])
|
||||
NUMBER = DBAPISet([FIELD_TYPE.DECIMAL, FIELD_TYPE.DOUBLE, FIELD_TYPE.FLOAT,
|
||||
FIELD_TYPE.INT24, FIELD_TYPE.LONG, FIELD_TYPE.LONGLONG,
|
||||
FIELD_TYPE.TINY, FIELD_TYPE.YEAR])
|
||||
DATE = DBAPISet([FIELD_TYPE.DATE, FIELD_TYPE.NEWDATE])
|
||||
TIME = DBAPISet([FIELD_TYPE.TIME])
|
||||
TIMESTAMP = DBAPISet([FIELD_TYPE.TIMESTAMP, FIELD_TYPE.DATETIME])
|
||||
DATETIME = TIMESTAMP
|
||||
ROWID = DBAPISet()
|
||||
|
||||
def test_DBAPISet_set_equality():
|
||||
assert STRING == STRING
|
||||
|
||||
def test_DBAPISet_set_inequality():
|
||||
assert STRING != NUMBER
|
||||
|
||||
def test_DBAPISet_set_equality_membership():
|
||||
assert FIELD_TYPE.VAR_STRING == STRING
|
||||
|
||||
def test_DBAPISet_set_inequality_membership():
|
||||
assert FIELD_TYPE.DATE != STRING
|
||||
|
||||
def Binary(x):
|
||||
return str(x)
|
||||
|
||||
def Connect(*args, **kwargs):
|
||||
"""Factory function for connections.Connection."""
|
||||
from MySQLdb.connections import Connection
|
||||
return Connection(*args, **kwargs)
|
||||
|
||||
connect = Connection = Connect
|
||||
|
||||
__all__ = [ 'BINARY', 'Binary', 'Connect', 'Connection', 'DATE',
|
||||
'Date', 'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks',
|
||||
'TimestampFromTicks', 'DataError', 'DatabaseError', 'Error',
|
||||
'FIELD_TYPE', 'IntegrityError', 'InterfaceError', 'InternalError',
|
||||
'MySQLError', 'NULL', 'NUMBER', 'NotSupportedError', 'DBAPISet',
|
||||
'OperationalError', 'ProgrammingError', 'ROWID', 'STRING', 'TIME',
|
||||
'TIMESTAMP', 'Warning', 'apilevel', 'connect', 'connections',
|
||||
'constants', 'converters', 'cursors', 'debug', 'escape', 'escape_dict',
|
||||
'escape_sequence', 'escape_string', 'get_client_info',
|
||||
'paramstyle', 'string_literal', 'threadsafety', 'version_info']
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,333 +1,333 @@
|
||||
"""
|
||||
|
||||
This module implements connections for MySQLdb. Presently there is
|
||||
only one class: Connection. Others are unlikely. However, you might
|
||||
want to make your own subclasses. In most cases, you will probably
|
||||
override Connection.default_cursor with a non-standard Cursor class.
|
||||
|
||||
"""
|
||||
from MySQLdb import cursors
|
||||
from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \
|
||||
DatabaseError, OperationalError, IntegrityError, InternalError, \
|
||||
NotSupportedError, ProgrammingError
|
||||
import types, _mysql
|
||||
import re
|
||||
|
||||
|
||||
def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
|
||||
"""
|
||||
|
||||
If cursor is not None, (errorclass, errorvalue) is appended to
|
||||
cursor.messages; otherwise it is appended to
|
||||
connection.messages. Then errorclass is raised with errorvalue as
|
||||
the value.
|
||||
|
||||
You can override this with your own error handler by assigning it
|
||||
to the instance.
|
||||
|
||||
"""
|
||||
error = errorclass, errorvalue
|
||||
if cursor:
|
||||
cursor.messages.append(error)
|
||||
else:
|
||||
connection.messages.append(error)
|
||||
del cursor
|
||||
del connection
|
||||
raise errorclass(errorvalue)
|
||||
|
||||
re_numeric_part = re.compile(r"^(\d+)")
|
||||
|
||||
def numeric_part(s):
|
||||
"""Returns the leading numeric part of a string.
|
||||
|
||||
>>> numeric_part("20-alpha")
|
||||
20
|
||||
>>> numeric_part("foo")
|
||||
>>> numeric_part("16b")
|
||||
16
|
||||
"""
|
||||
|
||||
m = re_numeric_part.match(s)
|
||||
if m:
|
||||
return int(m.group(1))
|
||||
return None
|
||||
|
||||
|
||||
class Connection(_mysql.connection):
|
||||
|
||||
"""MySQL Database Connection Object"""
|
||||
|
||||
default_cursor = cursors.Cursor
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
|
||||
Create a connection to the database. It is strongly recommended
|
||||
that you only use keyword parameters. Consult the MySQL C API
|
||||
documentation for more information.
|
||||
|
||||
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 to use
|
||||
|
||||
conv
|
||||
conversion dictionary, see MySQLdb.converters
|
||||
|
||||
connect_timeout
|
||||
number of seconds to wait before the connection attempt
|
||||
fails.
|
||||
|
||||
compress
|
||||
if set, compression is enabled
|
||||
|
||||
named_pipe
|
||||
if set, a named pipe is used to connect (Windows only)
|
||||
|
||||
init_command
|
||||
command which is run once the connection is created
|
||||
|
||||
read_default_file
|
||||
file from which default client values are read
|
||||
|
||||
read_default_group
|
||||
configuration group to use from the default file
|
||||
|
||||
cursorclass
|
||||
class object, used to create cursors (keyword only)
|
||||
|
||||
use_unicode
|
||||
If True, text-like columns are returned as unicode objects
|
||||
using the connection's character set. Otherwise, text-like
|
||||
columns are returned as strings. columns are returned as
|
||||
normal strings. Unicode objects will always be encoded to
|
||||
the connection's character set regardless of this setting.
|
||||
|
||||
charset
|
||||
If supplied, the connection character set will be changed
|
||||
to this character set (MySQL-4.1 and newer). This implies
|
||||
use_unicode=True.
|
||||
|
||||
sql_mode
|
||||
If supplied, the session SQL mode will be changed to this
|
||||
setting (MySQL-4.1 and newer). For more details and legal
|
||||
values, see the MySQL documentation.
|
||||
|
||||
client_flag
|
||||
integer, flags to use or 0
|
||||
(see MySQL docs or constants/CLIENTS.py)
|
||||
|
||||
ssl
|
||||
dictionary or mapping, contains SSL connection parameters;
|
||||
see the MySQL documentation for more details
|
||||
(mysql_ssl_set()). If this is set, and the client does not
|
||||
support SSL, NotSupportedError will be raised.
|
||||
|
||||
local_infile
|
||||
integer, non-zero enables LOAD LOCAL INFILE; zero disables
|
||||
|
||||
There are a number of undocumented, non-standard methods. See the
|
||||
documentation for the MySQL C API for some hints on what they do.
|
||||
|
||||
"""
|
||||
from MySQLdb.constants import CLIENT, FIELD_TYPE
|
||||
from MySQLdb.converters import conversions
|
||||
from weakref import proxy, WeakValueDictionary
|
||||
|
||||
import types
|
||||
|
||||
kwargs2 = kwargs.copy()
|
||||
|
||||
if 'conv' in kwargs:
|
||||
conv = kwargs['conv']
|
||||
else:
|
||||
conv = conversions
|
||||
|
||||
conv2 = {}
|
||||
for k, v in conv.items():
|
||||
if isinstance(k, int) and isinstance(v, list):
|
||||
conv2[k] = v[:]
|
||||
else:
|
||||
conv2[k] = v
|
||||
kwargs2['conv'] = conv2
|
||||
|
||||
cursorclass = kwargs2.pop('cursorclass', self.default_cursor)
|
||||
charset = kwargs2.pop('charset', '')
|
||||
|
||||
if charset:
|
||||
use_unicode = True
|
||||
else:
|
||||
use_unicode = False
|
||||
|
||||
use_unicode = kwargs2.pop('use_unicode', use_unicode)
|
||||
sql_mode = kwargs2.pop('sql_mode', '')
|
||||
|
||||
client_flag = kwargs.get('client_flag', 0)
|
||||
client_version = tuple([ numeric_part(n) for n in _mysql.get_client_info().split('.')[:2] ])
|
||||
if client_version >= (4, 1):
|
||||
client_flag |= CLIENT.MULTI_STATEMENTS
|
||||
if client_version >= (5, 0):
|
||||
client_flag |= CLIENT.MULTI_RESULTS
|
||||
|
||||
kwargs2['client_flag'] = client_flag
|
||||
|
||||
super(Connection, self).__init__(*args, **kwargs2)
|
||||
self.cursorclass = cursorclass
|
||||
self.encoders = dict([ (k, v) for k, v in conv.items()
|
||||
if type(k) is not int ])
|
||||
|
||||
self._server_version = tuple([ numeric_part(n) for n in self.get_server_info().split('.')[:2] ])
|
||||
|
||||
db = proxy(self)
|
||||
def _get_string_literal():
|
||||
def string_literal(obj, dummy=None):
|
||||
return db.string_literal(obj)
|
||||
return string_literal
|
||||
|
||||
def _get_unicode_literal():
|
||||
def unicode_literal(u, dummy=None):
|
||||
return db.literal(u.encode(unicode_literal.charset))
|
||||
return unicode_literal
|
||||
|
||||
def _get_string_decoder():
|
||||
def string_decoder(s):
|
||||
return s.decode(string_decoder.charset)
|
||||
return string_decoder
|
||||
|
||||
string_literal = _get_string_literal()
|
||||
self.unicode_literal = unicode_literal = _get_unicode_literal()
|
||||
self.string_decoder = string_decoder = _get_string_decoder()
|
||||
if not charset:
|
||||
charset = self.character_set_name()
|
||||
self.set_character_set(charset)
|
||||
|
||||
if sql_mode:
|
||||
self.set_sql_mode(sql_mode)
|
||||
|
||||
if use_unicode:
|
||||
self.converter[FIELD_TYPE.STRING].append((None, string_decoder))
|
||||
self.converter[FIELD_TYPE.VAR_STRING].append((None, string_decoder))
|
||||
self.converter[FIELD_TYPE.VARCHAR].append((None, string_decoder))
|
||||
self.converter[FIELD_TYPE.BLOB].append((None, string_decoder))
|
||||
|
||||
self.encoders[types.StringType] = string_literal
|
||||
self.encoders[types.UnicodeType] = unicode_literal
|
||||
self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS
|
||||
if self._transactional:
|
||||
# PEP-249 requires autocommit to be initially off
|
||||
self.autocommit(False)
|
||||
self.messages = []
|
||||
|
||||
def cursor(self, cursorclass=None):
|
||||
"""
|
||||
|
||||
Create a cursor on which queries may be performed. The
|
||||
optional cursorclass parameter is used to create the
|
||||
Cursor. By default, self.cursorclass=cursors.Cursor is
|
||||
used.
|
||||
|
||||
"""
|
||||
return (cursorclass or self.cursorclass)(self)
|
||||
|
||||
def __enter__(self): return self.cursor()
|
||||
|
||||
def __exit__(self, exc, value, tb):
|
||||
if exc:
|
||||
self.rollback()
|
||||
else:
|
||||
self.commit()
|
||||
|
||||
def literal(self, o):
|
||||
"""
|
||||
|
||||
If o is a single object, returns an SQL literal as a string.
|
||||
If o is a non-string sequence, the items of the sequence are
|
||||
converted and returned as a sequence.
|
||||
|
||||
Non-standard. For internal use; do not use this in your
|
||||
applications.
|
||||
|
||||
"""
|
||||
return self.escape(o, self.encoders)
|
||||
|
||||
def begin(self):
|
||||
"""Explicitly begin a connection. Non-standard.
|
||||
DEPRECATED: Will be removed in 1.3.
|
||||
Use an SQL BEGIN statement instead."""
|
||||
from warnings import warn
|
||||
warn("begin() is non-standard and will be removed in 1.3",
|
||||
DeprecationWarning, 2)
|
||||
self.query("BEGIN")
|
||||
|
||||
if not hasattr(_mysql.connection, 'warning_count'):
|
||||
|
||||
def warning_count(self):
|
||||
"""Return the number of warnings generated from the
|
||||
last query. This is derived from the info() method."""
|
||||
from string import atoi
|
||||
info = self.info()
|
||||
if info:
|
||||
return atoi(info.split()[-1])
|
||||
else:
|
||||
return 0
|
||||
|
||||
def set_character_set(self, charset):
|
||||
"""Set the connection character set to charset. The character
|
||||
set can only be changed in MySQL-4.1 and newer. If you try
|
||||
to change the character set from the current value in an
|
||||
older version, NotSupportedError will be raised."""
|
||||
if self.character_set_name() != charset:
|
||||
try:
|
||||
super(Connection, self).set_character_set(charset)
|
||||
except AttributeError:
|
||||
if self._server_version < (4, 1):
|
||||
raise NotSupportedError("server is too old to set charset")
|
||||
self.query('SET NAMES %s' % charset)
|
||||
self.store_result()
|
||||
self.string_decoder.charset = charset
|
||||
self.unicode_literal.charset = charset
|
||||
|
||||
def set_sql_mode(self, sql_mode):
|
||||
"""Set the connection sql_mode. See MySQL documentation for
|
||||
legal values."""
|
||||
if self._server_version < (4, 1):
|
||||
raise NotSupportedError("server is too old to set sql_mode")
|
||||
self.query("SET SESSION sql_mode='%s'" % sql_mode)
|
||||
self.store_result()
|
||||
|
||||
def show_warnings(self):
|
||||
"""Return detailed information about warnings as a
|
||||
sequence of tuples of (Level, Code, Message). This
|
||||
is only supported in MySQL-4.1 and up. If your server
|
||||
is an earlier version, an empty sequence is returned."""
|
||||
if self._server_version < (4,1): return ()
|
||||
self.query("SHOW WARNINGS")
|
||||
r = self.store_result()
|
||||
warnings = r.fetch_row(0)
|
||||
return warnings
|
||||
|
||||
Warning = Warning
|
||||
Error = Error
|
||||
InterfaceError = InterfaceError
|
||||
DatabaseError = DatabaseError
|
||||
DataError = DataError
|
||||
OperationalError = OperationalError
|
||||
IntegrityError = IntegrityError
|
||||
InternalError = InternalError
|
||||
ProgrammingError = ProgrammingError
|
||||
NotSupportedError = NotSupportedError
|
||||
|
||||
errorhandler = defaulterrorhandler
|
||||
"""
|
||||
|
||||
This module implements connections for MySQLdb. Presently there is
|
||||
only one class: Connection. Others are unlikely. However, you might
|
||||
want to make your own subclasses. In most cases, you will probably
|
||||
override Connection.default_cursor with a non-standard Cursor class.
|
||||
|
||||
"""
|
||||
from MySQLdb import cursors
|
||||
from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \
|
||||
DatabaseError, OperationalError, IntegrityError, InternalError, \
|
||||
NotSupportedError, ProgrammingError
|
||||
import types, _mysql
|
||||
import re
|
||||
|
||||
|
||||
def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
|
||||
"""
|
||||
|
||||
If cursor is not None, (errorclass, errorvalue) is appended to
|
||||
cursor.messages; otherwise it is appended to
|
||||
connection.messages. Then errorclass is raised with errorvalue as
|
||||
the value.
|
||||
|
||||
You can override this with your own error handler by assigning it
|
||||
to the instance.
|
||||
|
||||
"""
|
||||
error = errorclass, errorvalue
|
||||
if cursor:
|
||||
cursor.messages.append(error)
|
||||
else:
|
||||
connection.messages.append(error)
|
||||
del cursor
|
||||
del connection
|
||||
raise errorclass(errorvalue)
|
||||
|
||||
re_numeric_part = re.compile(r"^(\d+)")
|
||||
|
||||
def numeric_part(s):
|
||||
"""Returns the leading numeric part of a string.
|
||||
|
||||
>>> numeric_part("20-alpha")
|
||||
20
|
||||
>>> numeric_part("foo")
|
||||
>>> numeric_part("16b")
|
||||
16
|
||||
"""
|
||||
|
||||
m = re_numeric_part.match(s)
|
||||
if m:
|
||||
return int(m.group(1))
|
||||
return None
|
||||
|
||||
|
||||
class Connection(_mysql.connection):
|
||||
|
||||
"""MySQL Database Connection Object"""
|
||||
|
||||
default_cursor = cursors.Cursor
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
|
||||
Create a connection to the database. It is strongly recommended
|
||||
that you only use keyword parameters. Consult the MySQL C API
|
||||
documentation for more information.
|
||||
|
||||
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 to use
|
||||
|
||||
conv
|
||||
conversion dictionary, see MySQLdb.converters
|
||||
|
||||
connect_timeout
|
||||
number of seconds to wait before the connection attempt
|
||||
fails.
|
||||
|
||||
compress
|
||||
if set, compression is enabled
|
||||
|
||||
named_pipe
|
||||
if set, a named pipe is used to connect (Windows only)
|
||||
|
||||
init_command
|
||||
command which is run once the connection is created
|
||||
|
||||
read_default_file
|
||||
file from which default client values are read
|
||||
|
||||
read_default_group
|
||||
configuration group to use from the default file
|
||||
|
||||
cursorclass
|
||||
class object, used to create cursors (keyword only)
|
||||
|
||||
use_unicode
|
||||
If True, text-like columns are returned as unicode objects
|
||||
using the connection's character set. Otherwise, text-like
|
||||
columns are returned as strings. columns are returned as
|
||||
normal strings. Unicode objects will always be encoded to
|
||||
the connection's character set regardless of this setting.
|
||||
|
||||
charset
|
||||
If supplied, the connection character set will be changed
|
||||
to this character set (MySQL-4.1 and newer). This implies
|
||||
use_unicode=True.
|
||||
|
||||
sql_mode
|
||||
If supplied, the session SQL mode will be changed to this
|
||||
setting (MySQL-4.1 and newer). For more details and legal
|
||||
values, see the MySQL documentation.
|
||||
|
||||
client_flag
|
||||
integer, flags to use or 0
|
||||
(see MySQL docs or constants/CLIENTS.py)
|
||||
|
||||
ssl
|
||||
dictionary or mapping, contains SSL connection parameters;
|
||||
see the MySQL documentation for more details
|
||||
(mysql_ssl_set()). If this is set, and the client does not
|
||||
support SSL, NotSupportedError will be raised.
|
||||
|
||||
local_infile
|
||||
integer, non-zero enables LOAD LOCAL INFILE; zero disables
|
||||
|
||||
There are a number of undocumented, non-standard methods. See the
|
||||
documentation for the MySQL C API for some hints on what they do.
|
||||
|
||||
"""
|
||||
from MySQLdb.constants import CLIENT, FIELD_TYPE
|
||||
from MySQLdb.converters import conversions
|
||||
from weakref import proxy, WeakValueDictionary
|
||||
|
||||
import types
|
||||
|
||||
kwargs2 = kwargs.copy()
|
||||
|
||||
if 'conv' in kwargs:
|
||||
conv = kwargs['conv']
|
||||
else:
|
||||
conv = conversions
|
||||
|
||||
conv2 = {}
|
||||
for k, v in conv.items():
|
||||
if isinstance(k, int) and isinstance(v, list):
|
||||
conv2[k] = v[:]
|
||||
else:
|
||||
conv2[k] = v
|
||||
kwargs2['conv'] = conv2
|
||||
|
||||
cursorclass = kwargs2.pop('cursorclass', self.default_cursor)
|
||||
charset = kwargs2.pop('charset', '')
|
||||
|
||||
if charset:
|
||||
use_unicode = True
|
||||
else:
|
||||
use_unicode = False
|
||||
|
||||
use_unicode = kwargs2.pop('use_unicode', use_unicode)
|
||||
sql_mode = kwargs2.pop('sql_mode', '')
|
||||
|
||||
client_flag = kwargs.get('client_flag', 0)
|
||||
client_version = tuple([ numeric_part(n) for n in _mysql.get_client_info().split('.')[:2] ])
|
||||
if client_version >= (4, 1):
|
||||
client_flag |= CLIENT.MULTI_STATEMENTS
|
||||
if client_version >= (5, 0):
|
||||
client_flag |= CLIENT.MULTI_RESULTS
|
||||
|
||||
kwargs2['client_flag'] = client_flag
|
||||
|
||||
super(Connection, self).__init__(*args, **kwargs2)
|
||||
self.cursorclass = cursorclass
|
||||
self.encoders = dict([ (k, v) for k, v in conv.items()
|
||||
if type(k) is not int ])
|
||||
|
||||
self._server_version = tuple([ numeric_part(n) for n in self.get_server_info().split('.')[:2] ])
|
||||
|
||||
db = proxy(self)
|
||||
def _get_string_literal():
|
||||
def string_literal(obj, dummy=None):
|
||||
return db.string_literal(obj)
|
||||
return string_literal
|
||||
|
||||
def _get_unicode_literal():
|
||||
def unicode_literal(u, dummy=None):
|
||||
return db.literal(u.encode(unicode_literal.charset))
|
||||
return unicode_literal
|
||||
|
||||
def _get_string_decoder():
|
||||
def string_decoder(s):
|
||||
return s.decode(string_decoder.charset)
|
||||
return string_decoder
|
||||
|
||||
string_literal = _get_string_literal()
|
||||
self.unicode_literal = unicode_literal = _get_unicode_literal()
|
||||
self.string_decoder = string_decoder = _get_string_decoder()
|
||||
if not charset:
|
||||
charset = self.character_set_name()
|
||||
self.set_character_set(charset)
|
||||
|
||||
if sql_mode:
|
||||
self.set_sql_mode(sql_mode)
|
||||
|
||||
if use_unicode:
|
||||
self.converter[FIELD_TYPE.STRING].append((None, string_decoder))
|
||||
self.converter[FIELD_TYPE.VAR_STRING].append((None, string_decoder))
|
||||
self.converter[FIELD_TYPE.VARCHAR].append((None, string_decoder))
|
||||
self.converter[FIELD_TYPE.BLOB].append((None, string_decoder))
|
||||
|
||||
self.encoders[types.StringType] = string_literal
|
||||
self.encoders[types.UnicodeType] = unicode_literal
|
||||
self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS
|
||||
if self._transactional:
|
||||
# PEP-249 requires autocommit to be initially off
|
||||
self.autocommit(False)
|
||||
self.messages = []
|
||||
|
||||
def cursor(self, cursorclass=None):
|
||||
"""
|
||||
|
||||
Create a cursor on which queries may be performed. The
|
||||
optional cursorclass parameter is used to create the
|
||||
Cursor. By default, self.cursorclass=cursors.Cursor is
|
||||
used.
|
||||
|
||||
"""
|
||||
return (cursorclass or self.cursorclass)(self)
|
||||
|
||||
def __enter__(self): return self.cursor()
|
||||
|
||||
def __exit__(self, exc, value, tb):
|
||||
if exc:
|
||||
self.rollback()
|
||||
else:
|
||||
self.commit()
|
||||
|
||||
def literal(self, o):
|
||||
"""
|
||||
|
||||
If o is a single object, returns an SQL literal as a string.
|
||||
If o is a non-string sequence, the items of the sequence are
|
||||
converted and returned as a sequence.
|
||||
|
||||
Non-standard. For internal use; do not use this in your
|
||||
applications.
|
||||
|
||||
"""
|
||||
return self.escape(o, self.encoders)
|
||||
|
||||
def begin(self):
|
||||
"""Explicitly begin a connection. Non-standard.
|
||||
DEPRECATED: Will be removed in 1.3.
|
||||
Use an SQL BEGIN statement instead."""
|
||||
from warnings import warn
|
||||
warn("begin() is non-standard and will be removed in 1.3",
|
||||
DeprecationWarning, 2)
|
||||
self.query("BEGIN")
|
||||
|
||||
if not hasattr(_mysql.connection, 'warning_count'):
|
||||
|
||||
def warning_count(self):
|
||||
"""Return the number of warnings generated from the
|
||||
last query. This is derived from the info() method."""
|
||||
from string import atoi
|
||||
info = self.info()
|
||||
if info:
|
||||
return atoi(info.split()[-1])
|
||||
else:
|
||||
return 0
|
||||
|
||||
def set_character_set(self, charset):
|
||||
"""Set the connection character set to charset. The character
|
||||
set can only be changed in MySQL-4.1 and newer. If you try
|
||||
to change the character set from the current value in an
|
||||
older version, NotSupportedError will be raised."""
|
||||
if self.character_set_name() != charset:
|
||||
try:
|
||||
super(Connection, self).set_character_set(charset)
|
||||
except AttributeError:
|
||||
if self._server_version < (4, 1):
|
||||
raise NotSupportedError("server is too old to set charset")
|
||||
self.query('SET NAMES %s' % charset)
|
||||
self.store_result()
|
||||
self.string_decoder.charset = charset
|
||||
self.unicode_literal.charset = charset
|
||||
|
||||
def set_sql_mode(self, sql_mode):
|
||||
"""Set the connection sql_mode. See MySQL documentation for
|
||||
legal values."""
|
||||
if self._server_version < (4, 1):
|
||||
raise NotSupportedError("server is too old to set sql_mode")
|
||||
self.query("SET SESSION sql_mode='%s'" % sql_mode)
|
||||
self.store_result()
|
||||
|
||||
def show_warnings(self):
|
||||
"""Return detailed information about warnings as a
|
||||
sequence of tuples of (Level, Code, Message). This
|
||||
is only supported in MySQL-4.1 and up. If your server
|
||||
is an earlier version, an empty sequence is returned."""
|
||||
if self._server_version < (4,1): return ()
|
||||
self.query("SHOW WARNINGS")
|
||||
r = self.store_result()
|
||||
warnings = r.fetch_row(0)
|
||||
return warnings
|
||||
|
||||
Warning = Warning
|
||||
Error = Error
|
||||
InterfaceError = InterfaceError
|
||||
DatabaseError = DatabaseError
|
||||
DataError = DataError
|
||||
OperationalError = OperationalError
|
||||
IntegrityError = IntegrityError
|
||||
InternalError = InternalError
|
||||
ProgrammingError = ProgrammingError
|
||||
NotSupportedError = NotSupportedError
|
||||
|
||||
errorhandler = defaulterrorhandler
|
||||
|
||||
@@ -1 +1 @@
|
||||
*.pyc
|
||||
*.pyc
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
"""MySQL CLIENT constants
|
||||
|
||||
These constants are used when creating the connection. Use bitwise-OR
|
||||
(|) to combine options together, and pass them as the client_flags
|
||||
parameter to MySQLdb.Connection. For more information on these flags,
|
||||
see the MySQL C API documentation for mysql_real_connect().
|
||||
|
||||
"""
|
||||
|
||||
LONG_PASSWORD = 1
|
||||
FOUND_ROWS = 2
|
||||
LONG_FLAG = 4
|
||||
CONNECT_WITH_DB = 8
|
||||
NO_SCHEMA = 16
|
||||
COMPRESS = 32
|
||||
ODBC = 64
|
||||
LOCAL_FILES = 128
|
||||
IGNORE_SPACE = 256
|
||||
CHANGE_USER = 512
|
||||
INTERACTIVE = 1024
|
||||
SSL = 2048
|
||||
IGNORE_SIGPIPE = 4096
|
||||
TRANSACTIONS = 8192 # mysql_com.h was WRONG prior to 3.23.35
|
||||
RESERVED = 16384
|
||||
SECURE_CONNECTION = 32768
|
||||
MULTI_STATEMENTS = 65536
|
||||
MULTI_RESULTS = 131072
|
||||
|
||||
|
||||
"""MySQL CLIENT constants
|
||||
|
||||
These constants are used when creating the connection. Use bitwise-OR
|
||||
(|) to combine options together, and pass them as the client_flags
|
||||
parameter to MySQLdb.Connection. For more information on these flags,
|
||||
see the MySQL C API documentation for mysql_real_connect().
|
||||
|
||||
"""
|
||||
|
||||
LONG_PASSWORD = 1
|
||||
FOUND_ROWS = 2
|
||||
LONG_FLAG = 4
|
||||
CONNECT_WITH_DB = 8
|
||||
NO_SCHEMA = 16
|
||||
COMPRESS = 32
|
||||
ODBC = 64
|
||||
LOCAL_FILES = 128
|
||||
IGNORE_SPACE = 256
|
||||
CHANGE_USER = 512
|
||||
INTERACTIVE = 1024
|
||||
SSL = 2048
|
||||
IGNORE_SIGPIPE = 4096
|
||||
TRANSACTIONS = 8192 # mysql_com.h was WRONG prior to 3.23.35
|
||||
RESERVED = 16384
|
||||
SECURE_CONNECTION = 32768
|
||||
MULTI_STATEMENTS = 65536
|
||||
MULTI_RESULTS = 131072
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
"""MySQL Connection Errors
|
||||
|
||||
Nearly all of these raise OperationalError. COMMANDS_OUT_OF_SYNC
|
||||
raises ProgrammingError.
|
||||
|
||||
"""
|
||||
|
||||
MIN_ERROR = 2000
|
||||
MAX_ERROR = 2999
|
||||
UNKNOWN_ERROR = 2000
|
||||
SOCKET_CREATE_ERROR = 2001
|
||||
CONNECTION_ERROR = 2002
|
||||
CONN_HOST_ERROR = 2003
|
||||
IPSOCK_ERROR = 2004
|
||||
UNKNOWN_HOST = 2005
|
||||
SERVER_GONE_ERROR = 2006
|
||||
VERSION_ERROR = 2007
|
||||
OUT_OF_MEMORY = 2008
|
||||
WRONG_HOST_INFO = 2009
|
||||
LOCALHOST_CONNECTION = 2010
|
||||
TCP_CONNECTION = 2011
|
||||
SERVER_HANDSHAKE_ERR = 2012
|
||||
SERVER_LOST = 2013
|
||||
COMMANDS_OUT_OF_SYNC = 2014
|
||||
NAMEDPIPE_CONNECTION = 2015
|
||||
NAMEDPIPEWAIT_ERROR = 2016
|
||||
NAMEDPIPEOPEN_ERROR = 2017
|
||||
NAMEDPIPESETSTATE_ERROR = 2018
|
||||
CANT_READ_CHARSET = 2019
|
||||
NET_PACKET_TOO_LARGE = 2020
|
||||
"""MySQL Connection Errors
|
||||
|
||||
Nearly all of these raise OperationalError. COMMANDS_OUT_OF_SYNC
|
||||
raises ProgrammingError.
|
||||
|
||||
"""
|
||||
|
||||
MIN_ERROR = 2000
|
||||
MAX_ERROR = 2999
|
||||
UNKNOWN_ERROR = 2000
|
||||
SOCKET_CREATE_ERROR = 2001
|
||||
CONNECTION_ERROR = 2002
|
||||
CONN_HOST_ERROR = 2003
|
||||
IPSOCK_ERROR = 2004
|
||||
UNKNOWN_HOST = 2005
|
||||
SERVER_GONE_ERROR = 2006
|
||||
VERSION_ERROR = 2007
|
||||
OUT_OF_MEMORY = 2008
|
||||
WRONG_HOST_INFO = 2009
|
||||
LOCALHOST_CONNECTION = 2010
|
||||
TCP_CONNECTION = 2011
|
||||
SERVER_HANDSHAKE_ERR = 2012
|
||||
SERVER_LOST = 2013
|
||||
COMMANDS_OUT_OF_SYNC = 2014
|
||||
NAMEDPIPE_CONNECTION = 2015
|
||||
NAMEDPIPEWAIT_ERROR = 2016
|
||||
NAMEDPIPEOPEN_ERROR = 2017
|
||||
NAMEDPIPESETSTATE_ERROR = 2018
|
||||
CANT_READ_CHARSET = 2019
|
||||
NET_PACKET_TOO_LARGE = 2020
|
||||
|
||||
@@ -1,467 +1,467 @@
|
||||
"""MySQL ER Constants
|
||||
|
||||
These constants are error codes for the bulk of the error conditions
|
||||
that may occur.
|
||||
|
||||
"""
|
||||
|
||||
HASHCHK = 1000
|
||||
NISAMCHK = 1001
|
||||
NO = 1002
|
||||
YES = 1003
|
||||
CANT_CREATE_FILE = 1004
|
||||
CANT_CREATE_TABLE = 1005
|
||||
CANT_CREATE_DB = 1006
|
||||
DB_CREATE_EXISTS = 1007
|
||||
DB_DROP_EXISTS = 1008
|
||||
DB_DROP_DELETE = 1009
|
||||
DB_DROP_RMDIR = 1010
|
||||
CANT_DELETE_FILE = 1011
|
||||
CANT_FIND_SYSTEM_REC = 1012
|
||||
CANT_GET_STAT = 1013
|
||||
CANT_GET_WD = 1014
|
||||
CANT_LOCK = 1015
|
||||
CANT_OPEN_FILE = 1016
|
||||
FILE_NOT_FOUND = 1017
|
||||
CANT_READ_DIR = 1018
|
||||
CANT_SET_WD = 1019
|
||||
CHECKREAD = 1020
|
||||
DISK_FULL = 1021
|
||||
DUP_KEY = 1022
|
||||
ERROR_ON_CLOSE = 1023
|
||||
ERROR_ON_READ = 1024
|
||||
ERROR_ON_RENAME = 1025
|
||||
ERROR_ON_WRITE = 1026
|
||||
FILE_USED = 1027
|
||||
FILSORT_ABORT = 1028
|
||||
FORM_NOT_FOUND = 1029
|
||||
GET_ERRNO = 1030
|
||||
ILLEGAL_HA = 1031
|
||||
KEY_NOT_FOUND = 1032
|
||||
NOT_FORM_FILE = 1033
|
||||
NOT_KEYFILE = 1034
|
||||
OLD_KEYFILE = 1035
|
||||
OPEN_AS_READONLY = 1036
|
||||
OUTOFMEMORY = 1037
|
||||
OUT_OF_SORTMEMORY = 1038
|
||||
UNEXPECTED_EOF = 1039
|
||||
CON_COUNT_ERROR = 1040
|
||||
OUT_OF_RESOURCES = 1041
|
||||
BAD_HOST_ERROR = 1042
|
||||
HANDSHAKE_ERROR = 1043
|
||||
DBACCESS_DENIED_ERROR = 1044
|
||||
ACCESS_DENIED_ERROR = 1045
|
||||
NO_DB_ERROR = 1046
|
||||
UNKNOWN_COM_ERROR = 1047
|
||||
BAD_NULL_ERROR = 1048
|
||||
BAD_DB_ERROR = 1049
|
||||
TABLE_EXISTS_ERROR = 1050
|
||||
BAD_TABLE_ERROR = 1051
|
||||
NON_UNIQ_ERROR = 1052
|
||||
SERVER_SHUTDOWN = 1053
|
||||
BAD_FIELD_ERROR = 1054
|
||||
WRONG_FIELD_WITH_GROUP = 1055
|
||||
WRONG_GROUP_FIELD = 1056
|
||||
WRONG_SUM_SELECT = 1057
|
||||
WRONG_VALUE_COUNT = 1058
|
||||
TOO_LONG_IDENT = 1059
|
||||
DUP_FIELDNAME = 1060
|
||||
DUP_KEYNAME = 1061
|
||||
DUP_ENTRY = 1062
|
||||
WRONG_FIELD_SPEC = 1063
|
||||
PARSE_ERROR = 1064
|
||||
EMPTY_QUERY = 1065
|
||||
NONUNIQ_TABLE = 1066
|
||||
INVALID_DEFAULT = 1067
|
||||
MULTIPLE_PRI_KEY = 1068
|
||||
TOO_MANY_KEYS = 1069
|
||||
TOO_MANY_KEY_PARTS = 1070
|
||||
TOO_LONG_KEY = 1071
|
||||
KEY_COLUMN_DOES_NOT_EXITS = 1072
|
||||
BLOB_USED_AS_KEY = 1073
|
||||
TOO_BIG_FIELDLENGTH = 1074
|
||||
WRONG_AUTO_KEY = 1075
|
||||
READY = 1076
|
||||
NORMAL_SHUTDOWN = 1077
|
||||
GOT_SIGNAL = 1078
|
||||
SHUTDOWN_COMPLETE = 1079
|
||||
FORCING_CLOSE = 1080
|
||||
IPSOCK_ERROR = 1081
|
||||
NO_SUCH_INDEX = 1082
|
||||
WRONG_FIELD_TERMINATORS = 1083
|
||||
BLOBS_AND_NO_TERMINATED = 1084
|
||||
TEXTFILE_NOT_READABLE = 1085
|
||||
FILE_EXISTS_ERROR = 1086
|
||||
LOAD_INFO = 1087
|
||||
ALTER_INFO = 1088
|
||||
WRONG_SUB_KEY = 1089
|
||||
CANT_REMOVE_ALL_FIELDS = 1090
|
||||
CANT_DROP_FIELD_OR_KEY = 1091
|
||||
INSERT_INFO = 1092
|
||||
INSERT_TABLE_USED = 1093
|
||||
NO_SUCH_THREAD = 1094
|
||||
KILL_DENIED_ERROR = 1095
|
||||
NO_TABLES_USED = 1096
|
||||
TOO_BIG_SET = 1097
|
||||
NO_UNIQUE_LOGFILE = 1098
|
||||
TABLE_NOT_LOCKED_FOR_WRITE = 1099
|
||||
TABLE_NOT_LOCKED = 1100
|
||||
BLOB_CANT_HAVE_DEFAULT = 1101
|
||||
WRONG_DB_NAME = 1102
|
||||
WRONG_TABLE_NAME = 1103
|
||||
TOO_BIG_SELECT = 1104
|
||||
UNKNOWN_ERROR = 1105
|
||||
UNKNOWN_PROCEDURE = 1106
|
||||
WRONG_PARAMCOUNT_TO_PROCEDURE = 1107
|
||||
WRONG_PARAMETERS_TO_PROCEDURE = 1108
|
||||
UNKNOWN_TABLE = 1109
|
||||
FIELD_SPECIFIED_TWICE = 1110
|
||||
INVALID_GROUP_FUNC_USE = 1111
|
||||
UNSUPPORTED_EXTENSION = 1112
|
||||
TABLE_MUST_HAVE_COLUMNS = 1113
|
||||
RECORD_FILE_FULL = 1114
|
||||
UNKNOWN_CHARACTER_SET = 1115
|
||||
TOO_MANY_TABLES = 1116
|
||||
TOO_MANY_FIELDS = 1117
|
||||
TOO_BIG_ROWSIZE = 1118
|
||||
STACK_OVERRUN = 1119
|
||||
WRONG_OUTER_JOIN = 1120
|
||||
NULL_COLUMN_IN_INDEX = 1121
|
||||
CANT_FIND_UDF = 1122
|
||||
CANT_INITIALIZE_UDF = 1123
|
||||
UDF_NO_PATHS = 1124
|
||||
UDF_EXISTS = 1125
|
||||
CANT_OPEN_LIBRARY = 1126
|
||||
CANT_FIND_DL_ENTRY = 1127
|
||||
FUNCTION_NOT_DEFINED = 1128
|
||||
HOST_IS_BLOCKED = 1129
|
||||
HOST_NOT_PRIVILEGED = 1130
|
||||
PASSWORD_ANONYMOUS_USER = 1131
|
||||
PASSWORD_NOT_ALLOWED = 1132
|
||||
PASSWORD_NO_MATCH = 1133
|
||||
UPDATE_INFO = 1134
|
||||
CANT_CREATE_THREAD = 1135
|
||||
WRONG_VALUE_COUNT_ON_ROW = 1136
|
||||
CANT_REOPEN_TABLE = 1137
|
||||
INVALID_USE_OF_NULL = 1138
|
||||
REGEXP_ERROR = 1139
|
||||
MIX_OF_GROUP_FUNC_AND_FIELDS = 1140
|
||||
NONEXISTING_GRANT = 1141
|
||||
TABLEACCESS_DENIED_ERROR = 1142
|
||||
COLUMNACCESS_DENIED_ERROR = 1143
|
||||
ILLEGAL_GRANT_FOR_TABLE = 1144
|
||||
GRANT_WRONG_HOST_OR_USER = 1145
|
||||
NO_SUCH_TABLE = 1146
|
||||
NONEXISTING_TABLE_GRANT = 1147
|
||||
NOT_ALLOWED_COMMAND = 1148
|
||||
SYNTAX_ERROR = 1149
|
||||
DELAYED_CANT_CHANGE_LOCK = 1150
|
||||
TOO_MANY_DELAYED_THREADS = 1151
|
||||
ABORTING_CONNECTION = 1152
|
||||
NET_PACKET_TOO_LARGE = 1153
|
||||
NET_READ_ERROR_FROM_PIPE = 1154
|
||||
NET_FCNTL_ERROR = 1155
|
||||
NET_PACKETS_OUT_OF_ORDER = 1156
|
||||
NET_UNCOMPRESS_ERROR = 1157
|
||||
NET_READ_ERROR = 1158
|
||||
NET_READ_INTERRUPTED = 1159
|
||||
NET_ERROR_ON_WRITE = 1160
|
||||
NET_WRITE_INTERRUPTED = 1161
|
||||
TOO_LONG_STRING = 1162
|
||||
TABLE_CANT_HANDLE_BLOB = 1163
|
||||
TABLE_CANT_HANDLE_AUTO_INCREMENT = 1164
|
||||
DELAYED_INSERT_TABLE_LOCKED = 1165
|
||||
WRONG_COLUMN_NAME = 1166
|
||||
WRONG_KEY_COLUMN = 1167
|
||||
WRONG_MRG_TABLE = 1168
|
||||
DUP_UNIQUE = 1169
|
||||
BLOB_KEY_WITHOUT_LENGTH = 1170
|
||||
PRIMARY_CANT_HAVE_NULL = 1171
|
||||
TOO_MANY_ROWS = 1172
|
||||
REQUIRES_PRIMARY_KEY = 1173
|
||||
NO_RAID_COMPILED = 1174
|
||||
UPDATE_WITHOUT_KEY_IN_SAFE_MODE = 1175
|
||||
KEY_DOES_NOT_EXITS = 1176
|
||||
CHECK_NO_SUCH_TABLE = 1177
|
||||
CHECK_NOT_IMPLEMENTED = 1178
|
||||
CANT_DO_THIS_DURING_AN_TRANSACTION = 1179
|
||||
ERROR_DURING_COMMIT = 1180
|
||||
ERROR_DURING_ROLLBACK = 1181
|
||||
ERROR_DURING_FLUSH_LOGS = 1182
|
||||
ERROR_DURING_CHECKPOINT = 1183
|
||||
NEW_ABORTING_CONNECTION = 1184
|
||||
DUMP_NOT_IMPLEMENTED = 1185
|
||||
FLUSH_MASTER_BINLOG_CLOSED = 1186
|
||||
INDEX_REBUILD = 1187
|
||||
MASTER = 1188
|
||||
MASTER_NET_READ = 1189
|
||||
MASTER_NET_WRITE = 1190
|
||||
FT_MATCHING_KEY_NOT_FOUND = 1191
|
||||
LOCK_OR_ACTIVE_TRANSACTION = 1192
|
||||
UNKNOWN_SYSTEM_VARIABLE = 1193
|
||||
CRASHED_ON_USAGE = 1194
|
||||
CRASHED_ON_REPAIR = 1195
|
||||
WARNING_NOT_COMPLETE_ROLLBACK = 1196
|
||||
TRANS_CACHE_FULL = 1197
|
||||
SLAVE_MUST_STOP = 1198
|
||||
SLAVE_NOT_RUNNING = 1199
|
||||
BAD_SLAVE = 1200
|
||||
MASTER_INFO = 1201
|
||||
SLAVE_THREAD = 1202
|
||||
TOO_MANY_USER_CONNECTIONS = 1203
|
||||
SET_CONSTANTS_ONLY = 1204
|
||||
LOCK_WAIT_TIMEOUT = 1205
|
||||
LOCK_TABLE_FULL = 1206
|
||||
READ_ONLY_TRANSACTION = 1207
|
||||
DROP_DB_WITH_READ_LOCK = 1208
|
||||
CREATE_DB_WITH_READ_LOCK = 1209
|
||||
WRONG_ARGUMENTS = 1210
|
||||
NO_PERMISSION_TO_CREATE_USER = 1211
|
||||
UNION_TABLES_IN_DIFFERENT_DIR = 1212
|
||||
LOCK_DEADLOCK = 1213
|
||||
TABLE_CANT_HANDLE_FT = 1214
|
||||
CANNOT_ADD_FOREIGN = 1215
|
||||
NO_REFERENCED_ROW = 1216
|
||||
ROW_IS_REFERENCED = 1217
|
||||
CONNECT_TO_MASTER = 1218
|
||||
QUERY_ON_MASTER = 1219
|
||||
ERROR_WHEN_EXECUTING_COMMAND = 1220
|
||||
WRONG_USAGE = 1221
|
||||
WRONG_NUMBER_OF_COLUMNS_IN_SELECT = 1222
|
||||
CANT_UPDATE_WITH_READLOCK = 1223
|
||||
MIXING_NOT_ALLOWED = 1224
|
||||
DUP_ARGUMENT = 1225
|
||||
USER_LIMIT_REACHED = 1226
|
||||
SPECIFIC_ACCESS_DENIED_ERROR = 1227
|
||||
LOCAL_VARIABLE = 1228
|
||||
GLOBAL_VARIABLE = 1229
|
||||
NO_DEFAULT = 1230
|
||||
WRONG_VALUE_FOR_VAR = 1231
|
||||
WRONG_TYPE_FOR_VAR = 1232
|
||||
VAR_CANT_BE_READ = 1233
|
||||
CANT_USE_OPTION_HERE = 1234
|
||||
NOT_SUPPORTED_YET = 1235
|
||||
MASTER_FATAL_ERROR_READING_BINLOG = 1236
|
||||
SLAVE_IGNORED_TABLE = 1237
|
||||
INCORRECT_GLOBAL_LOCAL_VAR = 1238
|
||||
WRONG_FK_DEF = 1239
|
||||
KEY_REF_DO_NOT_MATCH_TABLE_REF = 1240
|
||||
OPERAND_COLUMNS = 1241
|
||||
SUBQUERY_NO_1_ROW = 1242
|
||||
UNKNOWN_STMT_HANDLER = 1243
|
||||
CORRUPT_HELP_DB = 1244
|
||||
CYCLIC_REFERENCE = 1245
|
||||
AUTO_CONVERT = 1246
|
||||
ILLEGAL_REFERENCE = 1247
|
||||
DERIVED_MUST_HAVE_ALIAS = 1248
|
||||
SELECT_REDUCED = 1249
|
||||
TABLENAME_NOT_ALLOWED_HERE = 1250
|
||||
NOT_SUPPORTED_AUTH_MODE = 1251
|
||||
SPATIAL_CANT_HAVE_NULL = 1252
|
||||
COLLATION_CHARSET_MISMATCH = 1253
|
||||
SLAVE_WAS_RUNNING = 1254
|
||||
SLAVE_WAS_NOT_RUNNING = 1255
|
||||
TOO_BIG_FOR_UNCOMPRESS = 1256
|
||||
ZLIB_Z_MEM_ERROR = 1257
|
||||
ZLIB_Z_BUF_ERROR = 1258
|
||||
ZLIB_Z_DATA_ERROR = 1259
|
||||
CUT_VALUE_GROUP_CONCAT = 1260
|
||||
WARN_TOO_FEW_RECORDS = 1261
|
||||
WARN_TOO_MANY_RECORDS = 1262
|
||||
WARN_NULL_TO_NOTNULL = 1263
|
||||
WARN_DATA_OUT_OF_RANGE = 1264
|
||||
WARN_DATA_TRUNCATED = 1265
|
||||
WARN_USING_OTHER_HANDLER = 1266
|
||||
CANT_AGGREGATE_2COLLATIONS = 1267
|
||||
DROP_USER = 1268
|
||||
REVOKE_GRANTS = 1269
|
||||
CANT_AGGREGATE_3COLLATIONS = 1270
|
||||
CANT_AGGREGATE_NCOLLATIONS = 1271
|
||||
VARIABLE_IS_NOT_STRUCT = 1272
|
||||
UNKNOWN_COLLATION = 1273
|
||||
SLAVE_IGNORED_SSL_PARAMS = 1274
|
||||
SERVER_IS_IN_SECURE_AUTH_MODE = 1275
|
||||
WARN_FIELD_RESOLVED = 1276
|
||||
BAD_SLAVE_UNTIL_COND = 1277
|
||||
MISSING_SKIP_SLAVE = 1278
|
||||
UNTIL_COND_IGNORED = 1279
|
||||
WRONG_NAME_FOR_INDEX = 1280
|
||||
WRONG_NAME_FOR_CATALOG = 1281
|
||||
WARN_QC_RESIZE = 1282
|
||||
BAD_FT_COLUMN = 1283
|
||||
UNKNOWN_KEY_CACHE = 1284
|
||||
WARN_HOSTNAME_WONT_WORK = 1285
|
||||
UNKNOWN_STORAGE_ENGINE = 1286
|
||||
WARN_DEPRECATED_SYNTAX = 1287
|
||||
NON_UPDATABLE_TABLE = 1288
|
||||
FEATURE_DISABLED = 1289
|
||||
OPTION_PREVENTS_STATEMENT = 1290
|
||||
DUPLICATED_VALUE_IN_TYPE = 1291
|
||||
TRUNCATED_WRONG_VALUE = 1292
|
||||
TOO_MUCH_AUTO_TIMESTAMP_COLS = 1293
|
||||
INVALID_ON_UPDATE = 1294
|
||||
UNSUPPORTED_PS = 1295
|
||||
GET_ERRMSG = 1296
|
||||
GET_TEMPORARY_ERRMSG = 1297
|
||||
UNKNOWN_TIME_ZONE = 1298
|
||||
WARN_INVALID_TIMESTAMP = 1299
|
||||
INVALID_CHARACTER_STRING = 1300
|
||||
WARN_ALLOWED_PACKET_OVERFLOWED = 1301
|
||||
CONFLICTING_DECLARATIONS = 1302
|
||||
SP_NO_RECURSIVE_CREATE = 1303
|
||||
SP_ALREADY_EXISTS = 1304
|
||||
SP_DOES_NOT_EXIST = 1305
|
||||
SP_DROP_FAILED = 1306
|
||||
SP_STORE_FAILED = 1307
|
||||
SP_LILABEL_MISMATCH = 1308
|
||||
SP_LABEL_REDEFINE = 1309
|
||||
SP_LABEL_MISMATCH = 1310
|
||||
SP_UNINIT_VAR = 1311
|
||||
SP_BADSELECT = 1312
|
||||
SP_BADRETURN = 1313
|
||||
SP_BADSTATEMENT = 1314
|
||||
UPDATE_LOG_DEPRECATED_IGNORED = 1315
|
||||
UPDATE_LOG_DEPRECATED_TRANSLATED = 1316
|
||||
QUERY_INTERRUPTED = 1317
|
||||
SP_WRONG_NO_OF_ARGS = 1318
|
||||
SP_COND_MISMATCH = 1319
|
||||
SP_NORETURN = 1320
|
||||
SP_NORETURNEND = 1321
|
||||
SP_BAD_CURSOR_QUERY = 1322
|
||||
SP_BAD_CURSOR_SELECT = 1323
|
||||
SP_CURSOR_MISMATCH = 1324
|
||||
SP_CURSOR_ALREADY_OPEN = 1325
|
||||
SP_CURSOR_NOT_OPEN = 1326
|
||||
SP_UNDECLARED_VAR = 1327
|
||||
SP_WRONG_NO_OF_FETCH_ARGS = 1328
|
||||
SP_FETCH_NO_DATA = 1329
|
||||
SP_DUP_PARAM = 1330
|
||||
SP_DUP_VAR = 1331
|
||||
SP_DUP_COND = 1332
|
||||
SP_DUP_CURS = 1333
|
||||
SP_CANT_ALTER = 1334
|
||||
SP_SUBSELECT_NYI = 1335
|
||||
STMT_NOT_ALLOWED_IN_SF_OR_TRG = 1336
|
||||
SP_VARCOND_AFTER_CURSHNDLR = 1337
|
||||
SP_CURSOR_AFTER_HANDLER = 1338
|
||||
SP_CASE_NOT_FOUND = 1339
|
||||
FPARSER_TOO_BIG_FILE = 1340
|
||||
FPARSER_BAD_HEADER = 1341
|
||||
FPARSER_EOF_IN_COMMENT = 1342
|
||||
FPARSER_ERROR_IN_PARAMETER = 1343
|
||||
FPARSER_EOF_IN_UNKNOWN_PARAMETER = 1344
|
||||
VIEW_NO_EXPLAIN = 1345
|
||||
FRM_UNKNOWN_TYPE = 1346
|
||||
WRONG_OBJECT = 1347
|
||||
NONUPDATEABLE_COLUMN = 1348
|
||||
VIEW_SELECT_DERIVED = 1349
|
||||
VIEW_SELECT_CLAUSE = 1350
|
||||
VIEW_SELECT_VARIABLE = 1351
|
||||
VIEW_SELECT_TMPTABLE = 1352
|
||||
VIEW_WRONG_LIST = 1353
|
||||
WARN_VIEW_MERGE = 1354
|
||||
WARN_VIEW_WITHOUT_KEY = 1355
|
||||
VIEW_INVALID = 1356
|
||||
SP_NO_DROP_SP = 1357
|
||||
SP_GOTO_IN_HNDLR = 1358
|
||||
TRG_ALREADY_EXISTS = 1359
|
||||
TRG_DOES_NOT_EXIST = 1360
|
||||
TRG_ON_VIEW_OR_TEMP_TABLE = 1361
|
||||
TRG_CANT_CHANGE_ROW = 1362
|
||||
TRG_NO_SUCH_ROW_IN_TRG = 1363
|
||||
NO_DEFAULT_FOR_FIELD = 1364
|
||||
DIVISION_BY_ZERO = 1365
|
||||
TRUNCATED_WRONG_VALUE_FOR_FIELD = 1366
|
||||
ILLEGAL_VALUE_FOR_TYPE = 1367
|
||||
VIEW_NONUPD_CHECK = 1368
|
||||
VIEW_CHECK_FAILED = 1369
|
||||
PROCACCESS_DENIED_ERROR = 1370
|
||||
RELAY_LOG_FAIL = 1371
|
||||
PASSWD_LENGTH = 1372
|
||||
UNKNOWN_TARGET_BINLOG = 1373
|
||||
IO_ERR_LOG_INDEX_READ = 1374
|
||||
BINLOG_PURGE_PROHIBITED = 1375
|
||||
FSEEK_FAIL = 1376
|
||||
BINLOG_PURGE_FATAL_ERR = 1377
|
||||
LOG_IN_USE = 1378
|
||||
LOG_PURGE_UNKNOWN_ERR = 1379
|
||||
RELAY_LOG_INIT = 1380
|
||||
NO_BINARY_LOGGING = 1381
|
||||
RESERVED_SYNTAX = 1382
|
||||
WSAS_FAILED = 1383
|
||||
DIFF_GROUPS_PROC = 1384
|
||||
NO_GROUP_FOR_PROC = 1385
|
||||
ORDER_WITH_PROC = 1386
|
||||
LOGGING_PROHIBIT_CHANGING_OF = 1387
|
||||
NO_FILE_MAPPING = 1388
|
||||
WRONG_MAGIC = 1389
|
||||
PS_MANY_PARAM = 1390
|
||||
KEY_PART_0 = 1391
|
||||
VIEW_CHECKSUM = 1392
|
||||
VIEW_MULTIUPDATE = 1393
|
||||
VIEW_NO_INSERT_FIELD_LIST = 1394
|
||||
VIEW_DELETE_MERGE_VIEW = 1395
|
||||
CANNOT_USER = 1396
|
||||
XAER_NOTA = 1397
|
||||
XAER_INVAL = 1398
|
||||
XAER_RMFAIL = 1399
|
||||
XAER_OUTSIDE = 1400
|
||||
XAER_RMERR = 1401
|
||||
XA_RBROLLBACK = 1402
|
||||
NONEXISTING_PROC_GRANT = 1403
|
||||
PROC_AUTO_GRANT_FAIL = 1404
|
||||
PROC_AUTO_REVOKE_FAIL = 1405
|
||||
DATA_TOO_LONG = 1406
|
||||
SP_BAD_SQLSTATE = 1407
|
||||
STARTUP = 1408
|
||||
LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR = 1409
|
||||
CANT_CREATE_USER_WITH_GRANT = 1410
|
||||
WRONG_VALUE_FOR_TYPE = 1411
|
||||
TABLE_DEF_CHANGED = 1412
|
||||
SP_DUP_HANDLER = 1413
|
||||
SP_NOT_VAR_ARG = 1414
|
||||
SP_NO_RETSET = 1415
|
||||
CANT_CREATE_GEOMETRY_OBJECT = 1416
|
||||
FAILED_ROUTINE_BREAK_BINLOG = 1417
|
||||
BINLOG_UNSAFE_ROUTINE = 1418
|
||||
BINLOG_CREATE_ROUTINE_NEED_SUPER = 1419
|
||||
EXEC_STMT_WITH_OPEN_CURSOR = 1420
|
||||
STMT_HAS_NO_OPEN_CURSOR = 1421
|
||||
COMMIT_NOT_ALLOWED_IN_SF_OR_TRG = 1422
|
||||
NO_DEFAULT_FOR_VIEW_FIELD = 1423
|
||||
SP_NO_RECURSION = 1424
|
||||
TOO_BIG_SCALE = 1425
|
||||
TOO_BIG_PRECISION = 1426
|
||||
M_BIGGER_THAN_D = 1427
|
||||
WRONG_LOCK_OF_SYSTEM_TABLE = 1428
|
||||
CONNECT_TO_FOREIGN_DATA_SOURCE = 1429
|
||||
QUERY_ON_FOREIGN_DATA_SOURCE = 1430
|
||||
FOREIGN_DATA_SOURCE_DOESNT_EXIST = 1431
|
||||
FOREIGN_DATA_STRING_INVALID_CANT_CREATE = 1432
|
||||
FOREIGN_DATA_STRING_INVALID = 1433
|
||||
CANT_CREATE_FEDERATED_TABLE = 1434
|
||||
TRG_IN_WRONG_SCHEMA = 1435
|
||||
STACK_OVERRUN_NEED_MORE = 1436
|
||||
TOO_LONG_BODY = 1437
|
||||
WARN_CANT_DROP_DEFAULT_KEYCACHE = 1438
|
||||
TOO_BIG_DISPLAYWIDTH = 1439
|
||||
XAER_DUPID = 1440
|
||||
DATETIME_FUNCTION_OVERFLOW = 1441
|
||||
CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG = 1442
|
||||
VIEW_PREVENT_UPDATE = 1443
|
||||
PS_NO_RECURSION = 1444
|
||||
SP_CANT_SET_AUTOCOMMIT = 1445
|
||||
MALFORMED_DEFINER = 1446
|
||||
VIEW_FRM_NO_USER = 1447
|
||||
VIEW_OTHER_USER = 1448
|
||||
NO_SUCH_USER = 1449
|
||||
FORBID_SCHEMA_CHANGE = 1450
|
||||
ROW_IS_REFERENCED_2 = 1451
|
||||
NO_REFERENCED_ROW_2 = 1452
|
||||
SP_BAD_VAR_SHADOW = 1453
|
||||
TRG_NO_DEFINER = 1454
|
||||
OLD_FILE_FORMAT = 1455
|
||||
SP_RECURSION_LIMIT = 1456
|
||||
SP_PROC_TABLE_CORRUPT = 1457
|
||||
ERROR_LAST = 1457
|
||||
|
||||
"""MySQL ER Constants
|
||||
|
||||
These constants are error codes for the bulk of the error conditions
|
||||
that may occur.
|
||||
|
||||
"""
|
||||
|
||||
HASHCHK = 1000
|
||||
NISAMCHK = 1001
|
||||
NO = 1002
|
||||
YES = 1003
|
||||
CANT_CREATE_FILE = 1004
|
||||
CANT_CREATE_TABLE = 1005
|
||||
CANT_CREATE_DB = 1006
|
||||
DB_CREATE_EXISTS = 1007
|
||||
DB_DROP_EXISTS = 1008
|
||||
DB_DROP_DELETE = 1009
|
||||
DB_DROP_RMDIR = 1010
|
||||
CANT_DELETE_FILE = 1011
|
||||
CANT_FIND_SYSTEM_REC = 1012
|
||||
CANT_GET_STAT = 1013
|
||||
CANT_GET_WD = 1014
|
||||
CANT_LOCK = 1015
|
||||
CANT_OPEN_FILE = 1016
|
||||
FILE_NOT_FOUND = 1017
|
||||
CANT_READ_DIR = 1018
|
||||
CANT_SET_WD = 1019
|
||||
CHECKREAD = 1020
|
||||
DISK_FULL = 1021
|
||||
DUP_KEY = 1022
|
||||
ERROR_ON_CLOSE = 1023
|
||||
ERROR_ON_READ = 1024
|
||||
ERROR_ON_RENAME = 1025
|
||||
ERROR_ON_WRITE = 1026
|
||||
FILE_USED = 1027
|
||||
FILSORT_ABORT = 1028
|
||||
FORM_NOT_FOUND = 1029
|
||||
GET_ERRNO = 1030
|
||||
ILLEGAL_HA = 1031
|
||||
KEY_NOT_FOUND = 1032
|
||||
NOT_FORM_FILE = 1033
|
||||
NOT_KEYFILE = 1034
|
||||
OLD_KEYFILE = 1035
|
||||
OPEN_AS_READONLY = 1036
|
||||
OUTOFMEMORY = 1037
|
||||
OUT_OF_SORTMEMORY = 1038
|
||||
UNEXPECTED_EOF = 1039
|
||||
CON_COUNT_ERROR = 1040
|
||||
OUT_OF_RESOURCES = 1041
|
||||
BAD_HOST_ERROR = 1042
|
||||
HANDSHAKE_ERROR = 1043
|
||||
DBACCESS_DENIED_ERROR = 1044
|
||||
ACCESS_DENIED_ERROR = 1045
|
||||
NO_DB_ERROR = 1046
|
||||
UNKNOWN_COM_ERROR = 1047
|
||||
BAD_NULL_ERROR = 1048
|
||||
BAD_DB_ERROR = 1049
|
||||
TABLE_EXISTS_ERROR = 1050
|
||||
BAD_TABLE_ERROR = 1051
|
||||
NON_UNIQ_ERROR = 1052
|
||||
SERVER_SHUTDOWN = 1053
|
||||
BAD_FIELD_ERROR = 1054
|
||||
WRONG_FIELD_WITH_GROUP = 1055
|
||||
WRONG_GROUP_FIELD = 1056
|
||||
WRONG_SUM_SELECT = 1057
|
||||
WRONG_VALUE_COUNT = 1058
|
||||
TOO_LONG_IDENT = 1059
|
||||
DUP_FIELDNAME = 1060
|
||||
DUP_KEYNAME = 1061
|
||||
DUP_ENTRY = 1062
|
||||
WRONG_FIELD_SPEC = 1063
|
||||
PARSE_ERROR = 1064
|
||||
EMPTY_QUERY = 1065
|
||||
NONUNIQ_TABLE = 1066
|
||||
INVALID_DEFAULT = 1067
|
||||
MULTIPLE_PRI_KEY = 1068
|
||||
TOO_MANY_KEYS = 1069
|
||||
TOO_MANY_KEY_PARTS = 1070
|
||||
TOO_LONG_KEY = 1071
|
||||
KEY_COLUMN_DOES_NOT_EXITS = 1072
|
||||
BLOB_USED_AS_KEY = 1073
|
||||
TOO_BIG_FIELDLENGTH = 1074
|
||||
WRONG_AUTO_KEY = 1075
|
||||
READY = 1076
|
||||
NORMAL_SHUTDOWN = 1077
|
||||
GOT_SIGNAL = 1078
|
||||
SHUTDOWN_COMPLETE = 1079
|
||||
FORCING_CLOSE = 1080
|
||||
IPSOCK_ERROR = 1081
|
||||
NO_SUCH_INDEX = 1082
|
||||
WRONG_FIELD_TERMINATORS = 1083
|
||||
BLOBS_AND_NO_TERMINATED = 1084
|
||||
TEXTFILE_NOT_READABLE = 1085
|
||||
FILE_EXISTS_ERROR = 1086
|
||||
LOAD_INFO = 1087
|
||||
ALTER_INFO = 1088
|
||||
WRONG_SUB_KEY = 1089
|
||||
CANT_REMOVE_ALL_FIELDS = 1090
|
||||
CANT_DROP_FIELD_OR_KEY = 1091
|
||||
INSERT_INFO = 1092
|
||||
INSERT_TABLE_USED = 1093
|
||||
NO_SUCH_THREAD = 1094
|
||||
KILL_DENIED_ERROR = 1095
|
||||
NO_TABLES_USED = 1096
|
||||
TOO_BIG_SET = 1097
|
||||
NO_UNIQUE_LOGFILE = 1098
|
||||
TABLE_NOT_LOCKED_FOR_WRITE = 1099
|
||||
TABLE_NOT_LOCKED = 1100
|
||||
BLOB_CANT_HAVE_DEFAULT = 1101
|
||||
WRONG_DB_NAME = 1102
|
||||
WRONG_TABLE_NAME = 1103
|
||||
TOO_BIG_SELECT = 1104
|
||||
UNKNOWN_ERROR = 1105
|
||||
UNKNOWN_PROCEDURE = 1106
|
||||
WRONG_PARAMCOUNT_TO_PROCEDURE = 1107
|
||||
WRONG_PARAMETERS_TO_PROCEDURE = 1108
|
||||
UNKNOWN_TABLE = 1109
|
||||
FIELD_SPECIFIED_TWICE = 1110
|
||||
INVALID_GROUP_FUNC_USE = 1111
|
||||
UNSUPPORTED_EXTENSION = 1112
|
||||
TABLE_MUST_HAVE_COLUMNS = 1113
|
||||
RECORD_FILE_FULL = 1114
|
||||
UNKNOWN_CHARACTER_SET = 1115
|
||||
TOO_MANY_TABLES = 1116
|
||||
TOO_MANY_FIELDS = 1117
|
||||
TOO_BIG_ROWSIZE = 1118
|
||||
STACK_OVERRUN = 1119
|
||||
WRONG_OUTER_JOIN = 1120
|
||||
NULL_COLUMN_IN_INDEX = 1121
|
||||
CANT_FIND_UDF = 1122
|
||||
CANT_INITIALIZE_UDF = 1123
|
||||
UDF_NO_PATHS = 1124
|
||||
UDF_EXISTS = 1125
|
||||
CANT_OPEN_LIBRARY = 1126
|
||||
CANT_FIND_DL_ENTRY = 1127
|
||||
FUNCTION_NOT_DEFINED = 1128
|
||||
HOST_IS_BLOCKED = 1129
|
||||
HOST_NOT_PRIVILEGED = 1130
|
||||
PASSWORD_ANONYMOUS_USER = 1131
|
||||
PASSWORD_NOT_ALLOWED = 1132
|
||||
PASSWORD_NO_MATCH = 1133
|
||||
UPDATE_INFO = 1134
|
||||
CANT_CREATE_THREAD = 1135
|
||||
WRONG_VALUE_COUNT_ON_ROW = 1136
|
||||
CANT_REOPEN_TABLE = 1137
|
||||
INVALID_USE_OF_NULL = 1138
|
||||
REGEXP_ERROR = 1139
|
||||
MIX_OF_GROUP_FUNC_AND_FIELDS = 1140
|
||||
NONEXISTING_GRANT = 1141
|
||||
TABLEACCESS_DENIED_ERROR = 1142
|
||||
COLUMNACCESS_DENIED_ERROR = 1143
|
||||
ILLEGAL_GRANT_FOR_TABLE = 1144
|
||||
GRANT_WRONG_HOST_OR_USER = 1145
|
||||
NO_SUCH_TABLE = 1146
|
||||
NONEXISTING_TABLE_GRANT = 1147
|
||||
NOT_ALLOWED_COMMAND = 1148
|
||||
SYNTAX_ERROR = 1149
|
||||
DELAYED_CANT_CHANGE_LOCK = 1150
|
||||
TOO_MANY_DELAYED_THREADS = 1151
|
||||
ABORTING_CONNECTION = 1152
|
||||
NET_PACKET_TOO_LARGE = 1153
|
||||
NET_READ_ERROR_FROM_PIPE = 1154
|
||||
NET_FCNTL_ERROR = 1155
|
||||
NET_PACKETS_OUT_OF_ORDER = 1156
|
||||
NET_UNCOMPRESS_ERROR = 1157
|
||||
NET_READ_ERROR = 1158
|
||||
NET_READ_INTERRUPTED = 1159
|
||||
NET_ERROR_ON_WRITE = 1160
|
||||
NET_WRITE_INTERRUPTED = 1161
|
||||
TOO_LONG_STRING = 1162
|
||||
TABLE_CANT_HANDLE_BLOB = 1163
|
||||
TABLE_CANT_HANDLE_AUTO_INCREMENT = 1164
|
||||
DELAYED_INSERT_TABLE_LOCKED = 1165
|
||||
WRONG_COLUMN_NAME = 1166
|
||||
WRONG_KEY_COLUMN = 1167
|
||||
WRONG_MRG_TABLE = 1168
|
||||
DUP_UNIQUE = 1169
|
||||
BLOB_KEY_WITHOUT_LENGTH = 1170
|
||||
PRIMARY_CANT_HAVE_NULL = 1171
|
||||
TOO_MANY_ROWS = 1172
|
||||
REQUIRES_PRIMARY_KEY = 1173
|
||||
NO_RAID_COMPILED = 1174
|
||||
UPDATE_WITHOUT_KEY_IN_SAFE_MODE = 1175
|
||||
KEY_DOES_NOT_EXITS = 1176
|
||||
CHECK_NO_SUCH_TABLE = 1177
|
||||
CHECK_NOT_IMPLEMENTED = 1178
|
||||
CANT_DO_THIS_DURING_AN_TRANSACTION = 1179
|
||||
ERROR_DURING_COMMIT = 1180
|
||||
ERROR_DURING_ROLLBACK = 1181
|
||||
ERROR_DURING_FLUSH_LOGS = 1182
|
||||
ERROR_DURING_CHECKPOINT = 1183
|
||||
NEW_ABORTING_CONNECTION = 1184
|
||||
DUMP_NOT_IMPLEMENTED = 1185
|
||||
FLUSH_MASTER_BINLOG_CLOSED = 1186
|
||||
INDEX_REBUILD = 1187
|
||||
MASTER = 1188
|
||||
MASTER_NET_READ = 1189
|
||||
MASTER_NET_WRITE = 1190
|
||||
FT_MATCHING_KEY_NOT_FOUND = 1191
|
||||
LOCK_OR_ACTIVE_TRANSACTION = 1192
|
||||
UNKNOWN_SYSTEM_VARIABLE = 1193
|
||||
CRASHED_ON_USAGE = 1194
|
||||
CRASHED_ON_REPAIR = 1195
|
||||
WARNING_NOT_COMPLETE_ROLLBACK = 1196
|
||||
TRANS_CACHE_FULL = 1197
|
||||
SLAVE_MUST_STOP = 1198
|
||||
SLAVE_NOT_RUNNING = 1199
|
||||
BAD_SLAVE = 1200
|
||||
MASTER_INFO = 1201
|
||||
SLAVE_THREAD = 1202
|
||||
TOO_MANY_USER_CONNECTIONS = 1203
|
||||
SET_CONSTANTS_ONLY = 1204
|
||||
LOCK_WAIT_TIMEOUT = 1205
|
||||
LOCK_TABLE_FULL = 1206
|
||||
READ_ONLY_TRANSACTION = 1207
|
||||
DROP_DB_WITH_READ_LOCK = 1208
|
||||
CREATE_DB_WITH_READ_LOCK = 1209
|
||||
WRONG_ARGUMENTS = 1210
|
||||
NO_PERMISSION_TO_CREATE_USER = 1211
|
||||
UNION_TABLES_IN_DIFFERENT_DIR = 1212
|
||||
LOCK_DEADLOCK = 1213
|
||||
TABLE_CANT_HANDLE_FT = 1214
|
||||
CANNOT_ADD_FOREIGN = 1215
|
||||
NO_REFERENCED_ROW = 1216
|
||||
ROW_IS_REFERENCED = 1217
|
||||
CONNECT_TO_MASTER = 1218
|
||||
QUERY_ON_MASTER = 1219
|
||||
ERROR_WHEN_EXECUTING_COMMAND = 1220
|
||||
WRONG_USAGE = 1221
|
||||
WRONG_NUMBER_OF_COLUMNS_IN_SELECT = 1222
|
||||
CANT_UPDATE_WITH_READLOCK = 1223
|
||||
MIXING_NOT_ALLOWED = 1224
|
||||
DUP_ARGUMENT = 1225
|
||||
USER_LIMIT_REACHED = 1226
|
||||
SPECIFIC_ACCESS_DENIED_ERROR = 1227
|
||||
LOCAL_VARIABLE = 1228
|
||||
GLOBAL_VARIABLE = 1229
|
||||
NO_DEFAULT = 1230
|
||||
WRONG_VALUE_FOR_VAR = 1231
|
||||
WRONG_TYPE_FOR_VAR = 1232
|
||||
VAR_CANT_BE_READ = 1233
|
||||
CANT_USE_OPTION_HERE = 1234
|
||||
NOT_SUPPORTED_YET = 1235
|
||||
MASTER_FATAL_ERROR_READING_BINLOG = 1236
|
||||
SLAVE_IGNORED_TABLE = 1237
|
||||
INCORRECT_GLOBAL_LOCAL_VAR = 1238
|
||||
WRONG_FK_DEF = 1239
|
||||
KEY_REF_DO_NOT_MATCH_TABLE_REF = 1240
|
||||
OPERAND_COLUMNS = 1241
|
||||
SUBQUERY_NO_1_ROW = 1242
|
||||
UNKNOWN_STMT_HANDLER = 1243
|
||||
CORRUPT_HELP_DB = 1244
|
||||
CYCLIC_REFERENCE = 1245
|
||||
AUTO_CONVERT = 1246
|
||||
ILLEGAL_REFERENCE = 1247
|
||||
DERIVED_MUST_HAVE_ALIAS = 1248
|
||||
SELECT_REDUCED = 1249
|
||||
TABLENAME_NOT_ALLOWED_HERE = 1250
|
||||
NOT_SUPPORTED_AUTH_MODE = 1251
|
||||
SPATIAL_CANT_HAVE_NULL = 1252
|
||||
COLLATION_CHARSET_MISMATCH = 1253
|
||||
SLAVE_WAS_RUNNING = 1254
|
||||
SLAVE_WAS_NOT_RUNNING = 1255
|
||||
TOO_BIG_FOR_UNCOMPRESS = 1256
|
||||
ZLIB_Z_MEM_ERROR = 1257
|
||||
ZLIB_Z_BUF_ERROR = 1258
|
||||
ZLIB_Z_DATA_ERROR = 1259
|
||||
CUT_VALUE_GROUP_CONCAT = 1260
|
||||
WARN_TOO_FEW_RECORDS = 1261
|
||||
WARN_TOO_MANY_RECORDS = 1262
|
||||
WARN_NULL_TO_NOTNULL = 1263
|
||||
WARN_DATA_OUT_OF_RANGE = 1264
|
||||
WARN_DATA_TRUNCATED = 1265
|
||||
WARN_USING_OTHER_HANDLER = 1266
|
||||
CANT_AGGREGATE_2COLLATIONS = 1267
|
||||
DROP_USER = 1268
|
||||
REVOKE_GRANTS = 1269
|
||||
CANT_AGGREGATE_3COLLATIONS = 1270
|
||||
CANT_AGGREGATE_NCOLLATIONS = 1271
|
||||
VARIABLE_IS_NOT_STRUCT = 1272
|
||||
UNKNOWN_COLLATION = 1273
|
||||
SLAVE_IGNORED_SSL_PARAMS = 1274
|
||||
SERVER_IS_IN_SECURE_AUTH_MODE = 1275
|
||||
WARN_FIELD_RESOLVED = 1276
|
||||
BAD_SLAVE_UNTIL_COND = 1277
|
||||
MISSING_SKIP_SLAVE = 1278
|
||||
UNTIL_COND_IGNORED = 1279
|
||||
WRONG_NAME_FOR_INDEX = 1280
|
||||
WRONG_NAME_FOR_CATALOG = 1281
|
||||
WARN_QC_RESIZE = 1282
|
||||
BAD_FT_COLUMN = 1283
|
||||
UNKNOWN_KEY_CACHE = 1284
|
||||
WARN_HOSTNAME_WONT_WORK = 1285
|
||||
UNKNOWN_STORAGE_ENGINE = 1286
|
||||
WARN_DEPRECATED_SYNTAX = 1287
|
||||
NON_UPDATABLE_TABLE = 1288
|
||||
FEATURE_DISABLED = 1289
|
||||
OPTION_PREVENTS_STATEMENT = 1290
|
||||
DUPLICATED_VALUE_IN_TYPE = 1291
|
||||
TRUNCATED_WRONG_VALUE = 1292
|
||||
TOO_MUCH_AUTO_TIMESTAMP_COLS = 1293
|
||||
INVALID_ON_UPDATE = 1294
|
||||
UNSUPPORTED_PS = 1295
|
||||
GET_ERRMSG = 1296
|
||||
GET_TEMPORARY_ERRMSG = 1297
|
||||
UNKNOWN_TIME_ZONE = 1298
|
||||
WARN_INVALID_TIMESTAMP = 1299
|
||||
INVALID_CHARACTER_STRING = 1300
|
||||
WARN_ALLOWED_PACKET_OVERFLOWED = 1301
|
||||
CONFLICTING_DECLARATIONS = 1302
|
||||
SP_NO_RECURSIVE_CREATE = 1303
|
||||
SP_ALREADY_EXISTS = 1304
|
||||
SP_DOES_NOT_EXIST = 1305
|
||||
SP_DROP_FAILED = 1306
|
||||
SP_STORE_FAILED = 1307
|
||||
SP_LILABEL_MISMATCH = 1308
|
||||
SP_LABEL_REDEFINE = 1309
|
||||
SP_LABEL_MISMATCH = 1310
|
||||
SP_UNINIT_VAR = 1311
|
||||
SP_BADSELECT = 1312
|
||||
SP_BADRETURN = 1313
|
||||
SP_BADSTATEMENT = 1314
|
||||
UPDATE_LOG_DEPRECATED_IGNORED = 1315
|
||||
UPDATE_LOG_DEPRECATED_TRANSLATED = 1316
|
||||
QUERY_INTERRUPTED = 1317
|
||||
SP_WRONG_NO_OF_ARGS = 1318
|
||||
SP_COND_MISMATCH = 1319
|
||||
SP_NORETURN = 1320
|
||||
SP_NORETURNEND = 1321
|
||||
SP_BAD_CURSOR_QUERY = 1322
|
||||
SP_BAD_CURSOR_SELECT = 1323
|
||||
SP_CURSOR_MISMATCH = 1324
|
||||
SP_CURSOR_ALREADY_OPEN = 1325
|
||||
SP_CURSOR_NOT_OPEN = 1326
|
||||
SP_UNDECLARED_VAR = 1327
|
||||
SP_WRONG_NO_OF_FETCH_ARGS = 1328
|
||||
SP_FETCH_NO_DATA = 1329
|
||||
SP_DUP_PARAM = 1330
|
||||
SP_DUP_VAR = 1331
|
||||
SP_DUP_COND = 1332
|
||||
SP_DUP_CURS = 1333
|
||||
SP_CANT_ALTER = 1334
|
||||
SP_SUBSELECT_NYI = 1335
|
||||
STMT_NOT_ALLOWED_IN_SF_OR_TRG = 1336
|
||||
SP_VARCOND_AFTER_CURSHNDLR = 1337
|
||||
SP_CURSOR_AFTER_HANDLER = 1338
|
||||
SP_CASE_NOT_FOUND = 1339
|
||||
FPARSER_TOO_BIG_FILE = 1340
|
||||
FPARSER_BAD_HEADER = 1341
|
||||
FPARSER_EOF_IN_COMMENT = 1342
|
||||
FPARSER_ERROR_IN_PARAMETER = 1343
|
||||
FPARSER_EOF_IN_UNKNOWN_PARAMETER = 1344
|
||||
VIEW_NO_EXPLAIN = 1345
|
||||
FRM_UNKNOWN_TYPE = 1346
|
||||
WRONG_OBJECT = 1347
|
||||
NONUPDATEABLE_COLUMN = 1348
|
||||
VIEW_SELECT_DERIVED = 1349
|
||||
VIEW_SELECT_CLAUSE = 1350
|
||||
VIEW_SELECT_VARIABLE = 1351
|
||||
VIEW_SELECT_TMPTABLE = 1352
|
||||
VIEW_WRONG_LIST = 1353
|
||||
WARN_VIEW_MERGE = 1354
|
||||
WARN_VIEW_WITHOUT_KEY = 1355
|
||||
VIEW_INVALID = 1356
|
||||
SP_NO_DROP_SP = 1357
|
||||
SP_GOTO_IN_HNDLR = 1358
|
||||
TRG_ALREADY_EXISTS = 1359
|
||||
TRG_DOES_NOT_EXIST = 1360
|
||||
TRG_ON_VIEW_OR_TEMP_TABLE = 1361
|
||||
TRG_CANT_CHANGE_ROW = 1362
|
||||
TRG_NO_SUCH_ROW_IN_TRG = 1363
|
||||
NO_DEFAULT_FOR_FIELD = 1364
|
||||
DIVISION_BY_ZERO = 1365
|
||||
TRUNCATED_WRONG_VALUE_FOR_FIELD = 1366
|
||||
ILLEGAL_VALUE_FOR_TYPE = 1367
|
||||
VIEW_NONUPD_CHECK = 1368
|
||||
VIEW_CHECK_FAILED = 1369
|
||||
PROCACCESS_DENIED_ERROR = 1370
|
||||
RELAY_LOG_FAIL = 1371
|
||||
PASSWD_LENGTH = 1372
|
||||
UNKNOWN_TARGET_BINLOG = 1373
|
||||
IO_ERR_LOG_INDEX_READ = 1374
|
||||
BINLOG_PURGE_PROHIBITED = 1375
|
||||
FSEEK_FAIL = 1376
|
||||
BINLOG_PURGE_FATAL_ERR = 1377
|
||||
LOG_IN_USE = 1378
|
||||
LOG_PURGE_UNKNOWN_ERR = 1379
|
||||
RELAY_LOG_INIT = 1380
|
||||
NO_BINARY_LOGGING = 1381
|
||||
RESERVED_SYNTAX = 1382
|
||||
WSAS_FAILED = 1383
|
||||
DIFF_GROUPS_PROC = 1384
|
||||
NO_GROUP_FOR_PROC = 1385
|
||||
ORDER_WITH_PROC = 1386
|
||||
LOGGING_PROHIBIT_CHANGING_OF = 1387
|
||||
NO_FILE_MAPPING = 1388
|
||||
WRONG_MAGIC = 1389
|
||||
PS_MANY_PARAM = 1390
|
||||
KEY_PART_0 = 1391
|
||||
VIEW_CHECKSUM = 1392
|
||||
VIEW_MULTIUPDATE = 1393
|
||||
VIEW_NO_INSERT_FIELD_LIST = 1394
|
||||
VIEW_DELETE_MERGE_VIEW = 1395
|
||||
CANNOT_USER = 1396
|
||||
XAER_NOTA = 1397
|
||||
XAER_INVAL = 1398
|
||||
XAER_RMFAIL = 1399
|
||||
XAER_OUTSIDE = 1400
|
||||
XAER_RMERR = 1401
|
||||
XA_RBROLLBACK = 1402
|
||||
NONEXISTING_PROC_GRANT = 1403
|
||||
PROC_AUTO_GRANT_FAIL = 1404
|
||||
PROC_AUTO_REVOKE_FAIL = 1405
|
||||
DATA_TOO_LONG = 1406
|
||||
SP_BAD_SQLSTATE = 1407
|
||||
STARTUP = 1408
|
||||
LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR = 1409
|
||||
CANT_CREATE_USER_WITH_GRANT = 1410
|
||||
WRONG_VALUE_FOR_TYPE = 1411
|
||||
TABLE_DEF_CHANGED = 1412
|
||||
SP_DUP_HANDLER = 1413
|
||||
SP_NOT_VAR_ARG = 1414
|
||||
SP_NO_RETSET = 1415
|
||||
CANT_CREATE_GEOMETRY_OBJECT = 1416
|
||||
FAILED_ROUTINE_BREAK_BINLOG = 1417
|
||||
BINLOG_UNSAFE_ROUTINE = 1418
|
||||
BINLOG_CREATE_ROUTINE_NEED_SUPER = 1419
|
||||
EXEC_STMT_WITH_OPEN_CURSOR = 1420
|
||||
STMT_HAS_NO_OPEN_CURSOR = 1421
|
||||
COMMIT_NOT_ALLOWED_IN_SF_OR_TRG = 1422
|
||||
NO_DEFAULT_FOR_VIEW_FIELD = 1423
|
||||
SP_NO_RECURSION = 1424
|
||||
TOO_BIG_SCALE = 1425
|
||||
TOO_BIG_PRECISION = 1426
|
||||
M_BIGGER_THAN_D = 1427
|
||||
WRONG_LOCK_OF_SYSTEM_TABLE = 1428
|
||||
CONNECT_TO_FOREIGN_DATA_SOURCE = 1429
|
||||
QUERY_ON_FOREIGN_DATA_SOURCE = 1430
|
||||
FOREIGN_DATA_SOURCE_DOESNT_EXIST = 1431
|
||||
FOREIGN_DATA_STRING_INVALID_CANT_CREATE = 1432
|
||||
FOREIGN_DATA_STRING_INVALID = 1433
|
||||
CANT_CREATE_FEDERATED_TABLE = 1434
|
||||
TRG_IN_WRONG_SCHEMA = 1435
|
||||
STACK_OVERRUN_NEED_MORE = 1436
|
||||
TOO_LONG_BODY = 1437
|
||||
WARN_CANT_DROP_DEFAULT_KEYCACHE = 1438
|
||||
TOO_BIG_DISPLAYWIDTH = 1439
|
||||
XAER_DUPID = 1440
|
||||
DATETIME_FUNCTION_OVERFLOW = 1441
|
||||
CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG = 1442
|
||||
VIEW_PREVENT_UPDATE = 1443
|
||||
PS_NO_RECURSION = 1444
|
||||
SP_CANT_SET_AUTOCOMMIT = 1445
|
||||
MALFORMED_DEFINER = 1446
|
||||
VIEW_FRM_NO_USER = 1447
|
||||
VIEW_OTHER_USER = 1448
|
||||
NO_SUCH_USER = 1449
|
||||
FORBID_SCHEMA_CHANGE = 1450
|
||||
ROW_IS_REFERENCED_2 = 1451
|
||||
NO_REFERENCED_ROW_2 = 1452
|
||||
SP_BAD_VAR_SHADOW = 1453
|
||||
TRG_NO_DEFINER = 1454
|
||||
OLD_FILE_FORMAT = 1455
|
||||
SP_RECURSION_LIMIT = 1456
|
||||
SP_PROC_TABLE_CORRUPT = 1457
|
||||
ERROR_LAST = 1457
|
||||
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
"""MySQL FIELD_TYPE Constants
|
||||
|
||||
These constants represent the various column (field) types that are
|
||||
supported by MySQL.
|
||||
|
||||
"""
|
||||
|
||||
DECIMAL = 0
|
||||
TINY = 1
|
||||
SHORT = 2
|
||||
LONG = 3
|
||||
FLOAT = 4
|
||||
DOUBLE = 5
|
||||
NULL = 6
|
||||
TIMESTAMP = 7
|
||||
LONGLONG = 8
|
||||
INT24 = 9
|
||||
DATE = 10
|
||||
TIME = 11
|
||||
DATETIME = 12
|
||||
YEAR = 13
|
||||
NEWDATE = 14
|
||||
VARCHAR = 15
|
||||
BIT = 16
|
||||
NEWDECIMAL = 246
|
||||
ENUM = 247
|
||||
SET = 248
|
||||
TINY_BLOB = 249
|
||||
MEDIUM_BLOB = 250
|
||||
LONG_BLOB = 251
|
||||
BLOB = 252
|
||||
VAR_STRING = 253
|
||||
STRING = 254
|
||||
GEOMETRY = 255
|
||||
|
||||
CHAR = TINY
|
||||
INTERVAL = ENUM
|
||||
"""MySQL FIELD_TYPE Constants
|
||||
|
||||
These constants represent the various column (field) types that are
|
||||
supported by MySQL.
|
||||
|
||||
"""
|
||||
|
||||
DECIMAL = 0
|
||||
TINY = 1
|
||||
SHORT = 2
|
||||
LONG = 3
|
||||
FLOAT = 4
|
||||
DOUBLE = 5
|
||||
NULL = 6
|
||||
TIMESTAMP = 7
|
||||
LONGLONG = 8
|
||||
INT24 = 9
|
||||
DATE = 10
|
||||
TIME = 11
|
||||
DATETIME = 12
|
||||
YEAR = 13
|
||||
NEWDATE = 14
|
||||
VARCHAR = 15
|
||||
BIT = 16
|
||||
NEWDECIMAL = 246
|
||||
ENUM = 247
|
||||
SET = 248
|
||||
TINY_BLOB = 249
|
||||
MEDIUM_BLOB = 250
|
||||
LONG_BLOB = 251
|
||||
BLOB = 252
|
||||
VAR_STRING = 253
|
||||
STRING = 254
|
||||
GEOMETRY = 255
|
||||
|
||||
CHAR = TINY
|
||||
INTERVAL = ENUM
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
"""MySQL FLAG Constants
|
||||
|
||||
These flags are used along with the FIELD_TYPE to indicate various
|
||||
properties of columns in a result set.
|
||||
|
||||
"""
|
||||
|
||||
NOT_NULL = 1
|
||||
PRI_KEY = 2
|
||||
UNIQUE_KEY = 4
|
||||
MULTIPLE_KEY = 8
|
||||
BLOB = 16
|
||||
UNSIGNED = 32
|
||||
ZEROFILL = 64
|
||||
BINARY = 128
|
||||
ENUM = 256
|
||||
AUTO_INCREMENT = 512
|
||||
TIMESTAMP = 1024
|
||||
SET = 2048
|
||||
NUM = 32768
|
||||
PART_KEY = 16384
|
||||
GROUP = 32768
|
||||
UNIQUE = 65536
|
||||
"""MySQL FLAG Constants
|
||||
|
||||
These flags are used along with the FIELD_TYPE to indicate various
|
||||
properties of columns in a result set.
|
||||
|
||||
"""
|
||||
|
||||
NOT_NULL = 1
|
||||
PRI_KEY = 2
|
||||
UNIQUE_KEY = 4
|
||||
MULTIPLE_KEY = 8
|
||||
BLOB = 16
|
||||
UNSIGNED = 32
|
||||
ZEROFILL = 64
|
||||
BINARY = 128
|
||||
ENUM = 256
|
||||
AUTO_INCREMENT = 512
|
||||
TIMESTAMP = 1024
|
||||
SET = 2048
|
||||
NUM = 32768
|
||||
PART_KEY = 16384
|
||||
GROUP = 32768
|
||||
UNIQUE = 65536
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
"""MySQL REFRESH Constants
|
||||
|
||||
These constants seem to mostly deal with things internal to the
|
||||
MySQL server. Forget you saw this.
|
||||
|
||||
"""
|
||||
|
||||
GRANT = 1
|
||||
LOG = 2
|
||||
TABLES = 4
|
||||
HOSTS = 8
|
||||
STATUS = 16
|
||||
THREADS = 32
|
||||
SLAVE = 64
|
||||
MASTER = 128
|
||||
READ_LOCK = 16384
|
||||
FAST = 32768
|
||||
"""MySQL REFRESH Constants
|
||||
|
||||
These constants seem to mostly deal with things internal to the
|
||||
MySQL server. Forget you saw this.
|
||||
|
||||
"""
|
||||
|
||||
GRANT = 1
|
||||
LOG = 2
|
||||
TABLES = 4
|
||||
HOSTS = 8
|
||||
STATUS = 16
|
||||
THREADS = 32
|
||||
SLAVE = 64
|
||||
MASTER = 128
|
||||
READ_LOCK = 16384
|
||||
FAST = 32768
|
||||
|
||||
@@ -1 +1 @@
|
||||
__all__ = ['CR', 'FIELD_TYPE','CLIENT','REFRESH','ER','FLAG']
|
||||
__all__ = ['CR', 'FIELD_TYPE','CLIENT','REFRESH','ER','FLAG']
|
||||
|
||||
@@ -1,181 +1,181 @@
|
||||
"""MySQLdb type conversion module
|
||||
|
||||
This module handles all the type conversions for MySQL. If the default
|
||||
type conversions aren't what you need, you can make your own. The
|
||||
dictionary conversions maps some kind of type to a conversion function
|
||||
which returns the corresponding value:
|
||||
|
||||
Key: FIELD_TYPE.* (from MySQLdb.constants)
|
||||
|
||||
Conversion function:
|
||||
|
||||
Arguments: string
|
||||
|
||||
Returns: Python object
|
||||
|
||||
Key: Python type object (from types) or class
|
||||
|
||||
Conversion function:
|
||||
|
||||
Arguments: Python object of indicated type or class AND
|
||||
conversion dictionary
|
||||
|
||||
Returns: SQL literal value
|
||||
|
||||
Notes: Most conversion functions can ignore the dictionary, but
|
||||
it is a required parameter. It is necessary for converting
|
||||
things like sequences and instances.
|
||||
|
||||
Don't modify conversions if you can avoid it. Instead, make copies
|
||||
(with the copy() method), modify the copies, and then pass them to
|
||||
MySQL.connect().
|
||||
|
||||
"""
|
||||
|
||||
from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL
|
||||
from MySQLdb.constants import FIELD_TYPE, FLAG
|
||||
from MySQLdb.times import *
|
||||
|
||||
try:
|
||||
from types import IntType, LongType, FloatType, NoneType, TupleType, ListType, DictType, InstanceType, \
|
||||
StringType, UnicodeType, ObjectType, BooleanType, ClassType, TypeType
|
||||
except ImportError:
|
||||
# Python 3
|
||||
long = int
|
||||
IntType, LongType, FloatType, NoneType = int, long, float, type(None)
|
||||
TupleType, ListType, DictType, InstanceType = tuple, list, dict, None
|
||||
StringType, UnicodeType, ObjectType, BooleanType = bytes, str, object, bool
|
||||
|
||||
import array
|
||||
|
||||
try:
|
||||
set
|
||||
except NameError:
|
||||
from sets import Set as set
|
||||
|
||||
def Bool2Str(s, d): return str(int(s))
|
||||
|
||||
def Str2Set(s):
|
||||
return set([ i for i in s.split(',') if i ])
|
||||
|
||||
def Set2Str(s, d):
|
||||
return string_literal(','.join(s), d)
|
||||
|
||||
def Thing2Str(s, d):
|
||||
"""Convert something into a string via str()."""
|
||||
return str(s)
|
||||
|
||||
def Unicode2Str(s, d):
|
||||
"""Convert a unicode object to a string using the default encoding.
|
||||
This is only used as a placeholder for the real function, which
|
||||
is connection-dependent."""
|
||||
return s.encode()
|
||||
|
||||
Long2Int = Thing2Str
|
||||
|
||||
def Float2Str(o, d):
|
||||
return '%.15g' % o
|
||||
|
||||
def None2NULL(o, d):
|
||||
"""Convert None to NULL."""
|
||||
return NULL # duh
|
||||
|
||||
def Thing2Literal(o, d):
|
||||
|
||||
"""Convert something into a SQL string literal. If using
|
||||
MySQL-3.23 or newer, string_literal() is a method of the
|
||||
_mysql.MYSQL object, and this function will be overridden with
|
||||
that method when the connection is created."""
|
||||
|
||||
return string_literal(o, d)
|
||||
|
||||
|
||||
def Instance2Str(o, d):
|
||||
|
||||
"""
|
||||
|
||||
Convert an Instance to a string representation. If the __str__()
|
||||
method produces acceptable output, then you don't need to add the
|
||||
class to conversions; it will be handled by the default
|
||||
converter. If the exact class is not found in d, it will use the
|
||||
first class it can find for which o is an instance.
|
||||
|
||||
"""
|
||||
|
||||
if o.__class__ in d:
|
||||
return d[o.__class__](o, d)
|
||||
cl = filter(lambda x,o=o:
|
||||
type(x) is ClassType
|
||||
and isinstance(o, x), d.keys())
|
||||
if not cl and hasattr(types, 'ObjectType'):
|
||||
cl = filter(lambda x,o=o:
|
||||
type(x) is TypeType
|
||||
and isinstance(o, x)
|
||||
and d[x] is not Instance2Str,
|
||||
d.keys())
|
||||
if not cl:
|
||||
return d[types.StringType](o,d)
|
||||
d[o.__class__] = d[cl[0]]
|
||||
return d[cl[0]](o, d)
|
||||
|
||||
def char_array(s):
|
||||
return array.array('c', s)
|
||||
|
||||
def array2Str(o, d):
|
||||
return Thing2Literal(o.tostring(), d)
|
||||
|
||||
conversions = {
|
||||
IntType: Thing2Str,
|
||||
LongType: Long2Int,
|
||||
FloatType: Float2Str,
|
||||
NoneType: None2NULL,
|
||||
TupleType: escape_sequence,
|
||||
ListType: escape_sequence,
|
||||
DictType: escape_dict,
|
||||
InstanceType: Instance2Str,
|
||||
array.ArrayType: array2Str,
|
||||
StringType: Thing2Literal, # default
|
||||
UnicodeType: Unicode2Str,
|
||||
ObjectType: Instance2Str,
|
||||
BooleanType: Bool2Str,
|
||||
DateTimeType: DateTime2literal,
|
||||
DateTimeDeltaType: DateTimeDelta2literal,
|
||||
set: Set2Str,
|
||||
FIELD_TYPE.TINY: int,
|
||||
FIELD_TYPE.SHORT: int,
|
||||
FIELD_TYPE.LONG: long,
|
||||
FIELD_TYPE.FLOAT: float,
|
||||
FIELD_TYPE.DOUBLE: float,
|
||||
FIELD_TYPE.DECIMAL: float,
|
||||
FIELD_TYPE.NEWDECIMAL: float,
|
||||
FIELD_TYPE.LONGLONG: long,
|
||||
FIELD_TYPE.INT24: int,
|
||||
FIELD_TYPE.YEAR: int,
|
||||
FIELD_TYPE.SET: Str2Set,
|
||||
FIELD_TYPE.TIMESTAMP: mysql_timestamp_converter,
|
||||
FIELD_TYPE.DATETIME: DateTime_or_None,
|
||||
FIELD_TYPE.TIME: TimeDelta_or_None,
|
||||
FIELD_TYPE.DATE: Date_or_None,
|
||||
FIELD_TYPE.BLOB: [
|
||||
(FLAG.BINARY, str),
|
||||
],
|
||||
FIELD_TYPE.STRING: [
|
||||
(FLAG.BINARY, str),
|
||||
],
|
||||
FIELD_TYPE.VAR_STRING: [
|
||||
(FLAG.BINARY, str),
|
||||
],
|
||||
FIELD_TYPE.VARCHAR: [
|
||||
(FLAG.BINARY, str),
|
||||
],
|
||||
}
|
||||
|
||||
try:
|
||||
from decimal import Decimal
|
||||
conversions[FIELD_TYPE.DECIMAL] = Decimal
|
||||
conversions[FIELD_TYPE.NEWDECIMAL] = Decimal
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
"""MySQLdb type conversion module
|
||||
|
||||
This module handles all the type conversions for MySQL. If the default
|
||||
type conversions aren't what you need, you can make your own. The
|
||||
dictionary conversions maps some kind of type to a conversion function
|
||||
which returns the corresponding value:
|
||||
|
||||
Key: FIELD_TYPE.* (from MySQLdb.constants)
|
||||
|
||||
Conversion function:
|
||||
|
||||
Arguments: string
|
||||
|
||||
Returns: Python object
|
||||
|
||||
Key: Python type object (from types) or class
|
||||
|
||||
Conversion function:
|
||||
|
||||
Arguments: Python object of indicated type or class AND
|
||||
conversion dictionary
|
||||
|
||||
Returns: SQL literal value
|
||||
|
||||
Notes: Most conversion functions can ignore the dictionary, but
|
||||
it is a required parameter. It is necessary for converting
|
||||
things like sequences and instances.
|
||||
|
||||
Don't modify conversions if you can avoid it. Instead, make copies
|
||||
(with the copy() method), modify the copies, and then pass them to
|
||||
MySQL.connect().
|
||||
|
||||
"""
|
||||
|
||||
from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL
|
||||
from MySQLdb.constants import FIELD_TYPE, FLAG
|
||||
from MySQLdb.times import *
|
||||
|
||||
try:
|
||||
from types import IntType, LongType, FloatType, NoneType, TupleType, ListType, DictType, InstanceType, \
|
||||
StringType, UnicodeType, ObjectType, BooleanType, ClassType, TypeType
|
||||
except ImportError:
|
||||
# Python 3
|
||||
long = int
|
||||
IntType, LongType, FloatType, NoneType = int, long, float, type(None)
|
||||
TupleType, ListType, DictType, InstanceType = tuple, list, dict, None
|
||||
StringType, UnicodeType, ObjectType, BooleanType = bytes, str, object, bool
|
||||
|
||||
import array
|
||||
|
||||
try:
|
||||
set
|
||||
except NameError:
|
||||
from sets import Set as set
|
||||
|
||||
def Bool2Str(s, d): return str(int(s))
|
||||
|
||||
def Str2Set(s):
|
||||
return set([ i for i in s.split(',') if i ])
|
||||
|
||||
def Set2Str(s, d):
|
||||
return string_literal(','.join(s), d)
|
||||
|
||||
def Thing2Str(s, d):
|
||||
"""Convert something into a string via str()."""
|
||||
return str(s)
|
||||
|
||||
def Unicode2Str(s, d):
|
||||
"""Convert a unicode object to a string using the default encoding.
|
||||
This is only used as a placeholder for the real function, which
|
||||
is connection-dependent."""
|
||||
return s.encode()
|
||||
|
||||
Long2Int = Thing2Str
|
||||
|
||||
def Float2Str(o, d):
|
||||
return '%.15g' % o
|
||||
|
||||
def None2NULL(o, d):
|
||||
"""Convert None to NULL."""
|
||||
return NULL # duh
|
||||
|
||||
def Thing2Literal(o, d):
|
||||
|
||||
"""Convert something into a SQL string literal. If using
|
||||
MySQL-3.23 or newer, string_literal() is a method of the
|
||||
_mysql.MYSQL object, and this function will be overridden with
|
||||
that method when the connection is created."""
|
||||
|
||||
return string_literal(o, d)
|
||||
|
||||
|
||||
def Instance2Str(o, d):
|
||||
|
||||
"""
|
||||
|
||||
Convert an Instance to a string representation. If the __str__()
|
||||
method produces acceptable output, then you don't need to add the
|
||||
class to conversions; it will be handled by the default
|
||||
converter. If the exact class is not found in d, it will use the
|
||||
first class it can find for which o is an instance.
|
||||
|
||||
"""
|
||||
|
||||
if o.__class__ in d:
|
||||
return d[o.__class__](o, d)
|
||||
cl = filter(lambda x,o=o:
|
||||
type(x) is ClassType
|
||||
and isinstance(o, x), d.keys())
|
||||
if not cl and hasattr(types, 'ObjectType'):
|
||||
cl = filter(lambda x,o=o:
|
||||
type(x) is TypeType
|
||||
and isinstance(o, x)
|
||||
and d[x] is not Instance2Str,
|
||||
d.keys())
|
||||
if not cl:
|
||||
return d[types.StringType](o,d)
|
||||
d[o.__class__] = d[cl[0]]
|
||||
return d[cl[0]](o, d)
|
||||
|
||||
def char_array(s):
|
||||
return array.array('c', s)
|
||||
|
||||
def array2Str(o, d):
|
||||
return Thing2Literal(o.tostring(), d)
|
||||
|
||||
conversions = {
|
||||
IntType: Thing2Str,
|
||||
LongType: Long2Int,
|
||||
FloatType: Float2Str,
|
||||
NoneType: None2NULL,
|
||||
TupleType: escape_sequence,
|
||||
ListType: escape_sequence,
|
||||
DictType: escape_dict,
|
||||
InstanceType: Instance2Str,
|
||||
array.ArrayType: array2Str,
|
||||
StringType: Thing2Literal, # default
|
||||
UnicodeType: Unicode2Str,
|
||||
ObjectType: Instance2Str,
|
||||
BooleanType: Bool2Str,
|
||||
DateTimeType: DateTime2literal,
|
||||
DateTimeDeltaType: DateTimeDelta2literal,
|
||||
set: Set2Str,
|
||||
FIELD_TYPE.TINY: int,
|
||||
FIELD_TYPE.SHORT: int,
|
||||
FIELD_TYPE.LONG: long,
|
||||
FIELD_TYPE.FLOAT: float,
|
||||
FIELD_TYPE.DOUBLE: float,
|
||||
FIELD_TYPE.DECIMAL: float,
|
||||
FIELD_TYPE.NEWDECIMAL: float,
|
||||
FIELD_TYPE.LONGLONG: long,
|
||||
FIELD_TYPE.INT24: int,
|
||||
FIELD_TYPE.YEAR: int,
|
||||
FIELD_TYPE.SET: Str2Set,
|
||||
FIELD_TYPE.TIMESTAMP: mysql_timestamp_converter,
|
||||
FIELD_TYPE.DATETIME: DateTime_or_None,
|
||||
FIELD_TYPE.TIME: TimeDelta_or_None,
|
||||
FIELD_TYPE.DATE: Date_or_None,
|
||||
FIELD_TYPE.BLOB: [
|
||||
(FLAG.BINARY, str),
|
||||
],
|
||||
FIELD_TYPE.STRING: [
|
||||
(FLAG.BINARY, str),
|
||||
],
|
||||
FIELD_TYPE.VAR_STRING: [
|
||||
(FLAG.BINARY, str),
|
||||
],
|
||||
FIELD_TYPE.VARCHAR: [
|
||||
(FLAG.BINARY, str),
|
||||
],
|
||||
}
|
||||
|
||||
try:
|
||||
from decimal import Decimal
|
||||
conversions[FIELD_TYPE.DECIMAL] = Decimal
|
||||
conversions[FIELD_TYPE.NEWDECIMAL] = Decimal
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,101 +1,101 @@
|
||||
"""times module
|
||||
|
||||
This module provides some Date and Time classes for dealing with MySQL data.
|
||||
|
||||
Use Python datetime module to handle date and time columns."""
|
||||
|
||||
import math
|
||||
from time import localtime
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from _mysql import string_literal
|
||||
|
||||
Date = date
|
||||
Time = time
|
||||
TimeDelta = timedelta
|
||||
Timestamp = datetime
|
||||
|
||||
DateTimeDeltaType = timedelta
|
||||
DateTimeType = datetime
|
||||
|
||||
def DateFromTicks(ticks):
|
||||
"""Convert UNIX ticks into a date instance."""
|
||||
return date(*localtime(ticks)[:3])
|
||||
|
||||
def TimeFromTicks(ticks):
|
||||
"""Convert UNIX ticks into a time instance."""
|
||||
return time(*localtime(ticks)[3:6])
|
||||
|
||||
def TimestampFromTicks(ticks):
|
||||
"""Convert UNIX ticks into a datetime instance."""
|
||||
return datetime(*localtime(ticks)[:6])
|
||||
|
||||
format_TIME = format_DATE = str
|
||||
|
||||
def format_TIMEDELTA(v):
|
||||
seconds = int(v.seconds) % 60
|
||||
minutes = int(v.seconds / 60) % 60
|
||||
hours = int(v.seconds / 3600) % 24
|
||||
return '%d %d:%d:%d' % (v.days, hours, minutes, seconds)
|
||||
|
||||
def format_TIMESTAMP(d):
|
||||
return d.isoformat(" ")
|
||||
|
||||
|
||||
def DateTime_or_None(s):
|
||||
if ' ' in s:
|
||||
sep = ' '
|
||||
elif 'T' in s:
|
||||
sep = 'T'
|
||||
else:
|
||||
return Date_or_None(s)
|
||||
|
||||
try:
|
||||
d, t = s.split(sep, 1)
|
||||
return datetime(*[ int(x) for x in d.split('-')+t.split(':') ])
|
||||
except:
|
||||
return Date_or_None(s)
|
||||
|
||||
def TimeDelta_or_None(s):
|
||||
try:
|
||||
h, m, s = s.split(':')
|
||||
h, m, s = int(h), int(m), float(s)
|
||||
td = timedelta(hours=abs(h), minutes=m, seconds=int(s),
|
||||
microseconds=int(math.modf(s)[0] * 1000000))
|
||||
if h < 0:
|
||||
return -td
|
||||
else:
|
||||
return td
|
||||
except ValueError:
|
||||
# unpacking or int/float conversion failed
|
||||
return None
|
||||
|
||||
def Time_or_None(s):
|
||||
try:
|
||||
h, m, s = s.split(':')
|
||||
h, m, s = int(h), int(m), float(s)
|
||||
return time(hour=h, minute=m, second=int(s),
|
||||
microsecond=int(math.modf(s)[0] * 1000000))
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
def Date_or_None(s):
|
||||
try: return date(*[ int(x) for x in s.split('-',2)])
|
||||
except: return None
|
||||
|
||||
def DateTime2literal(d, c):
|
||||
"""Format a DateTime object as an ISO timestamp."""
|
||||
return string_literal(format_TIMESTAMP(d),c)
|
||||
|
||||
def DateTimeDelta2literal(d, c):
|
||||
"""Format a DateTimeDelta object as a time."""
|
||||
return string_literal(format_TIMEDELTA(d),c)
|
||||
|
||||
def mysql_timestamp_converter(s):
|
||||
"""Convert a MySQL TIMESTAMP to a Timestamp object."""
|
||||
# MySQL>4.1 returns TIMESTAMP in the same format as DATETIME
|
||||
if s[4] == '-': return DateTime_or_None(s)
|
||||
s = s + "0"*(14-len(s)) # padding
|
||||
parts = map(int, filter(None, (s[:4],s[4:6],s[6:8],
|
||||
s[8:10],s[10:12],s[12:14])))
|
||||
try: return Timestamp(*parts)
|
||||
except: return None
|
||||
"""times module
|
||||
|
||||
This module provides some Date and Time classes for dealing with MySQL data.
|
||||
|
||||
Use Python datetime module to handle date and time columns."""
|
||||
|
||||
import math
|
||||
from time import localtime
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from _mysql import string_literal
|
||||
|
||||
Date = date
|
||||
Time = time
|
||||
TimeDelta = timedelta
|
||||
Timestamp = datetime
|
||||
|
||||
DateTimeDeltaType = timedelta
|
||||
DateTimeType = datetime
|
||||
|
||||
def DateFromTicks(ticks):
|
||||
"""Convert UNIX ticks into a date instance."""
|
||||
return date(*localtime(ticks)[:3])
|
||||
|
||||
def TimeFromTicks(ticks):
|
||||
"""Convert UNIX ticks into a time instance."""
|
||||
return time(*localtime(ticks)[3:6])
|
||||
|
||||
def TimestampFromTicks(ticks):
|
||||
"""Convert UNIX ticks into a datetime instance."""
|
||||
return datetime(*localtime(ticks)[:6])
|
||||
|
||||
format_TIME = format_DATE = str
|
||||
|
||||
def format_TIMEDELTA(v):
|
||||
seconds = int(v.seconds) % 60
|
||||
minutes = int(v.seconds / 60) % 60
|
||||
hours = int(v.seconds / 3600) % 24
|
||||
return '%d %d:%d:%d' % (v.days, hours, minutes, seconds)
|
||||
|
||||
def format_TIMESTAMP(d):
|
||||
return d.isoformat(" ")
|
||||
|
||||
|
||||
def DateTime_or_None(s):
|
||||
if ' ' in s:
|
||||
sep = ' '
|
||||
elif 'T' in s:
|
||||
sep = 'T'
|
||||
else:
|
||||
return Date_or_None(s)
|
||||
|
||||
try:
|
||||
d, t = s.split(sep, 1)
|
||||
return datetime(*[ int(x) for x in d.split('-')+t.split(':') ])
|
||||
except:
|
||||
return Date_or_None(s)
|
||||
|
||||
def TimeDelta_or_None(s):
|
||||
try:
|
||||
h, m, s = s.split(':')
|
||||
h, m, s = int(h), int(m), float(s)
|
||||
td = timedelta(hours=abs(h), minutes=m, seconds=int(s),
|
||||
microseconds=int(math.modf(s)[0] * 1000000))
|
||||
if h < 0:
|
||||
return -td
|
||||
else:
|
||||
return td
|
||||
except ValueError:
|
||||
# unpacking or int/float conversion failed
|
||||
return None
|
||||
|
||||
def Time_or_None(s):
|
||||
try:
|
||||
h, m, s = s.split(':')
|
||||
h, m, s = int(h), int(m), float(s)
|
||||
return time(hour=h, minute=m, second=int(s),
|
||||
microsecond=int(math.modf(s)[0] * 1000000))
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
def Date_or_None(s):
|
||||
try: return date(*[ int(x) for x in s.split('-',2)])
|
||||
except: return None
|
||||
|
||||
def DateTime2literal(d, c):
|
||||
"""Format a DateTime object as an ISO timestamp."""
|
||||
return string_literal(format_TIMESTAMP(d),c)
|
||||
|
||||
def DateTimeDelta2literal(d, c):
|
||||
"""Format a DateTimeDelta object as a time."""
|
||||
return string_literal(format_TIMEDELTA(d),c)
|
||||
|
||||
def mysql_timestamp_converter(s):
|
||||
"""Convert a MySQL TIMESTAMP to a Timestamp object."""
|
||||
# MySQL>4.1 returns TIMESTAMP in the same format as DATETIME
|
||||
if s[4] == '-': return DateTime_or_None(s)
|
||||
s = s + "0"*(14-len(s)) # padding
|
||||
parts = map(int, filter(None, (s[:4],s[4:6],s[6:8],
|
||||
s[8:10],s[10:12],s[12:14])))
|
||||
try: return Timestamp(*parts)
|
||||
except: return None
|
||||
|
||||
506
MySQLdb/README
506
MySQLdb/README
@@ -1,253 +1,253 @@
|
||||
====================
|
||||
MySQLdb Installation
|
||||
====================
|
||||
|
||||
.. contents::
|
||||
..
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
+ Python 2.3.4 or higher
|
||||
|
||||
* http://www.python.org/
|
||||
|
||||
* Versions lower than 2.3 WON'T WORK.
|
||||
|
||||
* 2.4 is the primary test environment.
|
||||
|
||||
* Red Hat Linux:
|
||||
|
||||
- Make sure you have the Python development headers and libraries
|
||||
(python-devel).
|
||||
|
||||
+ setuptools
|
||||
|
||||
* http://pypi.python.org/pypi/setuptools
|
||||
|
||||
+ MySQL 3.23.32 or higher
|
||||
|
||||
* http://www.mysql.com/downloads/
|
||||
|
||||
* Versions lower than 3.22 definitely WON'T WORK.
|
||||
|
||||
* Versions lower than 3.22.19 might not work.
|
||||
|
||||
* MySQL-3.22 might work but isn't supported anymore. It's very old.
|
||||
|
||||
* MySQL-3.23 ought to work, but it's pretty elderly.
|
||||
|
||||
* MySQL-4.0 is supported, but not tested and slightly discouraged.
|
||||
|
||||
* MySQL-4.1 is supported. The prepared statements API is not
|
||||
supported, and won't be until MySQLdb-1.3 or 2.0, if ever.
|
||||
|
||||
* MySQL-5.0 is supported and tested, including stored procedures.
|
||||
|
||||
* MySQL-5.1 is supported (currently a release candidate) but untested.
|
||||
It should work.
|
||||
|
||||
* MySQL-6.0 is sorta-kinda-supported (currently alpha) but untested.
|
||||
It should work.
|
||||
|
||||
* Drizzle <https://launchpad.net/drizzle> is a fork of MySQL. So far
|
||||
the C API looks really similar except everything is renamed.
|
||||
Drizzle support probably won't happen in 1.2. There may be have to
|
||||
be an entirely different module, but still using DB-API.
|
||||
|
||||
* MaxDB, formerly known as SAP DB (and maybe Adabas D?), is a
|
||||
completely different animal. Use the sapdb.sql module that comes
|
||||
with MaxDB.
|
||||
|
||||
* Red Hat Linux packages:
|
||||
|
||||
- mysql-devel to compile
|
||||
|
||||
- mysql and/or mysql-devel to run
|
||||
|
||||
* MySQL.com RPM packages:
|
||||
|
||||
- MySQL-devel to compile
|
||||
|
||||
- MySQL-shared if you want to use their shared
|
||||
library. Otherwise you'll get a statically-linked module,
|
||||
which may or may not be what you want.
|
||||
|
||||
- MySQL-shared to run if you compiled with MySQL-shared installed
|
||||
|
||||
* Transactions (particularly InnoDB tables) are supported for
|
||||
MySQL-3.23 and up. You may need a special package from your vendor
|
||||
with this support turned on.
|
||||
|
||||
+ zlib
|
||||
|
||||
* Required for MySQL-3.23 and newer.
|
||||
|
||||
* Red Hat Linux
|
||||
|
||||
- zlib-devel to compile
|
||||
|
||||
- zlib to run
|
||||
|
||||
+ openssl
|
||||
|
||||
* May be needed for MySQL-4.0 or newer, depending on compilation
|
||||
options. If you need it, you probably already have it.
|
||||
|
||||
- you may need openssl-devel on some platforms
|
||||
|
||||
+ C compiler
|
||||
|
||||
* Most free software-based systems already have this, usually gcc.
|
||||
|
||||
* Most commercial UNIX platforms also come with a C compiler, or
|
||||
you can also use gcc.
|
||||
|
||||
* If you have some Windows flavor, you usually have to pay extra
|
||||
for this, or you can use Cygwin_.
|
||||
|
||||
.. _Cygwin: http://www.cygwin.com/
|
||||
|
||||
|
||||
Building and installing
|
||||
-----------------------
|
||||
|
||||
The setup.py script uses mysql_config to find all compiler and linker
|
||||
options, and should work as is on any POSIX-like platform, so long as
|
||||
mysql_config is in your path.
|
||||
|
||||
Depending on which version of MySQL you have, you may have the option
|
||||
of using three different client libraries. To select the client library,
|
||||
edit the [options] section of site.cfg:
|
||||
|
||||
embedded
|
||||
use embedded server library (libmysqld) if True; otherwise use
|
||||
one of the client libraries (default).
|
||||
|
||||
threadsafe
|
||||
thread-safe client library (libmysqlclient_r) if True (default);
|
||||
otherwise use non-thread-safe (libmysqlclient). You should
|
||||
always use the thread-safe library if you have the option;
|
||||
otherwise you *may* have problems.
|
||||
|
||||
static
|
||||
if True, try to link against a static library; otherwise link
|
||||
against dynamic libraries (default). You may need static linking
|
||||
to use the embedded server.
|
||||
|
||||
|
||||
Finally, putting it together::
|
||||
|
||||
$ tar xfz MySQL-python-1.2.1.tar.gz
|
||||
$ cd MySQL-python-1.2.1
|
||||
$ # edit site.cfg if necessary
|
||||
$ python setup.py build
|
||||
$ sudo python setup.py install # or su first
|
||||
|
||||
|
||||
Windows
|
||||
.......
|
||||
|
||||
I don't do Windows. However if someone provides me with a package for
|
||||
Windows, I'll make it available. Don't ask me for help with Windows
|
||||
because I can't help you.
|
||||
|
||||
Generally, though, running setup.py is similar to above::
|
||||
|
||||
C:\...> python setup.py install
|
||||
C:\...> python setup.py bdist_wininst
|
||||
|
||||
The latter example should build a Windows installer package, if you
|
||||
have the correct tools. In any event, you *must* have a C compiler.
|
||||
Additionally, you have to set an environment variable (mysqlroot)
|
||||
which is the path to your MySQL installation. In theory, it would be
|
||||
possible to get this information out of the registry, but like I said,
|
||||
I don't do Windows, but I'll accept a patch that does this.
|
||||
|
||||
On Windows, you will definitely have to edit site.cfg since there is
|
||||
no mysql_config in the MySQL package.
|
||||
|
||||
|
||||
Zope
|
||||
....
|
||||
|
||||
If you are using a binary package of Zope, you need run setup.py with
|
||||
the python executable that came with Zope. Otherwise, you'll install
|
||||
into the wrong Python tree and Zope (ZMySQLDA) will not be able to
|
||||
find _mysql.
|
||||
|
||||
|
||||
Binary Packages
|
||||
---------------
|
||||
|
||||
I don't plan to make binary packages any more. However, if someone
|
||||
contributes one, I will make it available. Several OS vendors have
|
||||
their own packages available.
|
||||
|
||||
|
||||
RPMs
|
||||
....
|
||||
|
||||
If you prefer to install RPMs, you can use the bdist_rpm command with
|
||||
setup.py. This only builds the RPM; it does not install it. You may
|
||||
want to use the --python=XXX option, where XXX is the name of the
|
||||
Python executable, i.e. python, python2, python2.4; the default is
|
||||
python. Using this will incorporate the Python executable name into
|
||||
the package name for the RPM so you have install the package multiple
|
||||
times if you need to support more than one version of Python. You can
|
||||
also set this in setup.cfg.
|
||||
|
||||
|
||||
Red Hat Linux
|
||||
.............
|
||||
|
||||
MySQL-python is pre-packaged in Red Hat Linux 7.x and newer. This
|
||||
includes Fedora Core and Red Hat Enterprise Linux. You can also
|
||||
build your own RPM packages as described above.
|
||||
|
||||
|
||||
Debian GNU/Linux
|
||||
................
|
||||
|
||||
Packaged as `python-mysqldb`_::
|
||||
|
||||
# apt-get install python-mysqldb
|
||||
|
||||
Or use Synaptic.
|
||||
|
||||
.. _`python-mysqldb`: http://packages.debian.org/python-mysqldb
|
||||
|
||||
|
||||
Ubuntu
|
||||
......
|
||||
|
||||
Same as with Debian.
|
||||
|
||||
|
||||
Gentoo Linux
|
||||
............
|
||||
|
||||
Packaged as `mysql-python`_. ::
|
||||
|
||||
# emerge sync
|
||||
# emerge mysql-python
|
||||
# emerge zmysqlda # if you use Zope
|
||||
|
||||
.. _`mysql-python`: http://packages.gentoo.org/search/?sstring=mysql-python
|
||||
|
||||
|
||||
BSD
|
||||
...
|
||||
|
||||
MySQL-python is a ported package in FreeBSD, NetBSD, and OpenBSD,
|
||||
although the name may vary to match OS conventions.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
GPL or the original license based on Python 1.5.2's license.
|
||||
|
||||
|
||||
:Author: Andy Dustman <andy@dustman.net>
|
||||
:Revision: $Id$
|
||||
====================
|
||||
MySQLdb Installation
|
||||
====================
|
||||
|
||||
.. contents::
|
||||
..
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
+ Python 2.3.4 or higher
|
||||
|
||||
* http://www.python.org/
|
||||
|
||||
* Versions lower than 2.3 WON'T WORK.
|
||||
|
||||
* 2.4 is the primary test environment.
|
||||
|
||||
* Red Hat Linux:
|
||||
|
||||
- Make sure you have the Python development headers and libraries
|
||||
(python-devel).
|
||||
|
||||
+ setuptools
|
||||
|
||||
* http://pypi.python.org/pypi/setuptools
|
||||
|
||||
+ MySQL 3.23.32 or higher
|
||||
|
||||
* http://www.mysql.com/downloads/
|
||||
|
||||
* Versions lower than 3.22 definitely WON'T WORK.
|
||||
|
||||
* Versions lower than 3.22.19 might not work.
|
||||
|
||||
* MySQL-3.22 might work but isn't supported anymore. It's very old.
|
||||
|
||||
* MySQL-3.23 ought to work, but it's pretty elderly.
|
||||
|
||||
* MySQL-4.0 is supported, but not tested and slightly discouraged.
|
||||
|
||||
* MySQL-4.1 is supported. The prepared statements API is not
|
||||
supported, and won't be until MySQLdb-1.3 or 2.0, if ever.
|
||||
|
||||
* MySQL-5.0 is supported and tested, including stored procedures.
|
||||
|
||||
* MySQL-5.1 is supported (currently a release candidate) but untested.
|
||||
It should work.
|
||||
|
||||
* MySQL-6.0 is sorta-kinda-supported (currently alpha) but untested.
|
||||
It should work.
|
||||
|
||||
* Drizzle <https://launchpad.net/drizzle> is a fork of MySQL. So far
|
||||
the C API looks really similar except everything is renamed.
|
||||
Drizzle support probably won't happen in 1.2. There may be have to
|
||||
be an entirely different module, but still using DB-API.
|
||||
|
||||
* MaxDB, formerly known as SAP DB (and maybe Adabas D?), is a
|
||||
completely different animal. Use the sapdb.sql module that comes
|
||||
with MaxDB.
|
||||
|
||||
* Red Hat Linux packages:
|
||||
|
||||
- mysql-devel to compile
|
||||
|
||||
- mysql and/or mysql-devel to run
|
||||
|
||||
* MySQL.com RPM packages:
|
||||
|
||||
- MySQL-devel to compile
|
||||
|
||||
- MySQL-shared if you want to use their shared
|
||||
library. Otherwise you'll get a statically-linked module,
|
||||
which may or may not be what you want.
|
||||
|
||||
- MySQL-shared to run if you compiled with MySQL-shared installed
|
||||
|
||||
* Transactions (particularly InnoDB tables) are supported for
|
||||
MySQL-3.23 and up. You may need a special package from your vendor
|
||||
with this support turned on.
|
||||
|
||||
+ zlib
|
||||
|
||||
* Required for MySQL-3.23 and newer.
|
||||
|
||||
* Red Hat Linux
|
||||
|
||||
- zlib-devel to compile
|
||||
|
||||
- zlib to run
|
||||
|
||||
+ openssl
|
||||
|
||||
* May be needed for MySQL-4.0 or newer, depending on compilation
|
||||
options. If you need it, you probably already have it.
|
||||
|
||||
- you may need openssl-devel on some platforms
|
||||
|
||||
+ C compiler
|
||||
|
||||
* Most free software-based systems already have this, usually gcc.
|
||||
|
||||
* Most commercial UNIX platforms also come with a C compiler, or
|
||||
you can also use gcc.
|
||||
|
||||
* If you have some Windows flavor, you usually have to pay extra
|
||||
for this, or you can use Cygwin_.
|
||||
|
||||
.. _Cygwin: http://www.cygwin.com/
|
||||
|
||||
|
||||
Building and installing
|
||||
-----------------------
|
||||
|
||||
The setup.py script uses mysql_config to find all compiler and linker
|
||||
options, and should work as is on any POSIX-like platform, so long as
|
||||
mysql_config is in your path.
|
||||
|
||||
Depending on which version of MySQL you have, you may have the option
|
||||
of using three different client libraries. To select the client library,
|
||||
edit the [options] section of site.cfg:
|
||||
|
||||
embedded
|
||||
use embedded server library (libmysqld) if True; otherwise use
|
||||
one of the client libraries (default).
|
||||
|
||||
threadsafe
|
||||
thread-safe client library (libmysqlclient_r) if True (default);
|
||||
otherwise use non-thread-safe (libmysqlclient). You should
|
||||
always use the thread-safe library if you have the option;
|
||||
otherwise you *may* have problems.
|
||||
|
||||
static
|
||||
if True, try to link against a static library; otherwise link
|
||||
against dynamic libraries (default). You may need static linking
|
||||
to use the embedded server.
|
||||
|
||||
|
||||
Finally, putting it together::
|
||||
|
||||
$ tar xfz MySQL-python-1.2.1.tar.gz
|
||||
$ cd MySQL-python-1.2.1
|
||||
$ # edit site.cfg if necessary
|
||||
$ python setup.py build
|
||||
$ sudo python setup.py install # or su first
|
||||
|
||||
|
||||
Windows
|
||||
.......
|
||||
|
||||
I don't do Windows. However if someone provides me with a package for
|
||||
Windows, I'll make it available. Don't ask me for help with Windows
|
||||
because I can't help you.
|
||||
|
||||
Generally, though, running setup.py is similar to above::
|
||||
|
||||
C:\...> python setup.py install
|
||||
C:\...> python setup.py bdist_wininst
|
||||
|
||||
The latter example should build a Windows installer package, if you
|
||||
have the correct tools. In any event, you *must* have a C compiler.
|
||||
Additionally, you have to set an environment variable (mysqlroot)
|
||||
which is the path to your MySQL installation. In theory, it would be
|
||||
possible to get this information out of the registry, but like I said,
|
||||
I don't do Windows, but I'll accept a patch that does this.
|
||||
|
||||
On Windows, you will definitely have to edit site.cfg since there is
|
||||
no mysql_config in the MySQL package.
|
||||
|
||||
|
||||
Zope
|
||||
....
|
||||
|
||||
If you are using a binary package of Zope, you need run setup.py with
|
||||
the python executable that came with Zope. Otherwise, you'll install
|
||||
into the wrong Python tree and Zope (ZMySQLDA) will not be able to
|
||||
find _mysql.
|
||||
|
||||
|
||||
Binary Packages
|
||||
---------------
|
||||
|
||||
I don't plan to make binary packages any more. However, if someone
|
||||
contributes one, I will make it available. Several OS vendors have
|
||||
their own packages available.
|
||||
|
||||
|
||||
RPMs
|
||||
....
|
||||
|
||||
If you prefer to install RPMs, you can use the bdist_rpm command with
|
||||
setup.py. This only builds the RPM; it does not install it. You may
|
||||
want to use the --python=XXX option, where XXX is the name of the
|
||||
Python executable, i.e. python, python2, python2.4; the default is
|
||||
python. Using this will incorporate the Python executable name into
|
||||
the package name for the RPM so you have install the package multiple
|
||||
times if you need to support more than one version of Python. You can
|
||||
also set this in setup.cfg.
|
||||
|
||||
|
||||
Red Hat Linux
|
||||
.............
|
||||
|
||||
MySQL-python is pre-packaged in Red Hat Linux 7.x and newer. This
|
||||
includes Fedora Core and Red Hat Enterprise Linux. You can also
|
||||
build your own RPM packages as described above.
|
||||
|
||||
|
||||
Debian GNU/Linux
|
||||
................
|
||||
|
||||
Packaged as `python-mysqldb`_::
|
||||
|
||||
# apt-get install python-mysqldb
|
||||
|
||||
Or use Synaptic.
|
||||
|
||||
.. _`python-mysqldb`: http://packages.debian.org/python-mysqldb
|
||||
|
||||
|
||||
Ubuntu
|
||||
......
|
||||
|
||||
Same as with Debian.
|
||||
|
||||
|
||||
Gentoo Linux
|
||||
............
|
||||
|
||||
Packaged as `mysql-python`_. ::
|
||||
|
||||
# emerge sync
|
||||
# emerge mysql-python
|
||||
# emerge zmysqlda # if you use Zope
|
||||
|
||||
.. _`mysql-python`: http://packages.gentoo.org/search/?sstring=mysql-python
|
||||
|
||||
|
||||
BSD
|
||||
...
|
||||
|
||||
MySQL-python is a ported package in FreeBSD, NetBSD, and OpenBSD,
|
||||
although the name may vary to match OS conventions.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
GPL or the original license based on Python 1.5.2's license.
|
||||
|
||||
|
||||
:Author: Andy Dustman <andy@dustman.net>
|
||||
:Revision: $Id$
|
||||
|
||||
6158
MySQLdb/_mysql.c
6158
MySQLdb/_mysql.c
File diff suppressed because it is too large
Load Diff
@@ -1,87 +1,87 @@
|
||||
"""_mysql_exceptions: Exception classes for _mysql and MySQLdb.
|
||||
|
||||
These classes are dictated by the DB API v2.0:
|
||||
|
||||
http://www.python.org/topics/database/DatabaseAPI-2.0.html
|
||||
"""
|
||||
|
||||
try:
|
||||
from exceptions import Exception, StandardError, Warning
|
||||
except ImportError:
|
||||
# Python 3
|
||||
StandardError = Exception
|
||||
|
||||
|
||||
class MySQLError(StandardError):
|
||||
|
||||
"""Exception related to operation with MySQL."""
|
||||
|
||||
|
||||
class Warning(Warning, MySQLError):
|
||||
|
||||
"""Exception raised for important warnings like data truncations
|
||||
while inserting, etc."""
|
||||
|
||||
class Error(MySQLError):
|
||||
|
||||
"""Exception that is the base class of all other error exceptions
|
||||
(not Warning)."""
|
||||
|
||||
|
||||
class InterfaceError(Error):
|
||||
|
||||
"""Exception raised for errors that are related to the database
|
||||
interface rather than the database itself."""
|
||||
|
||||
|
||||
class DatabaseError(Error):
|
||||
|
||||
"""Exception raised for errors that are related to the
|
||||
database."""
|
||||
|
||||
|
||||
class DataError(DatabaseError):
|
||||
|
||||
"""Exception raised for errors that are due to problems with the
|
||||
processed data like division by zero, numeric value out of range,
|
||||
etc."""
|
||||
|
||||
|
||||
class OperationalError(DatabaseError):
|
||||
|
||||
"""Exception raised for errors that are related to the database's
|
||||
operation and not necessarily under the control of the programmer,
|
||||
e.g. an unexpected disconnect occurs, the data source name is not
|
||||
found, a transaction could not be processed, a memory allocation
|
||||
error occurred during processing, etc."""
|
||||
|
||||
|
||||
class IntegrityError(DatabaseError):
|
||||
|
||||
"""Exception raised when the relational integrity of the database
|
||||
is affected, e.g. a foreign key check fails, duplicate key,
|
||||
etc."""
|
||||
|
||||
|
||||
class InternalError(DatabaseError):
|
||||
|
||||
"""Exception raised when the database encounters an internal
|
||||
error, e.g. the cursor is not valid anymore, the transaction is
|
||||
out of sync, etc."""
|
||||
|
||||
|
||||
class ProgrammingError(DatabaseError):
|
||||
|
||||
"""Exception raised for programming errors, e.g. table not found
|
||||
or already exists, syntax error in the SQL statement, wrong number
|
||||
of parameters specified, etc."""
|
||||
|
||||
|
||||
class NotSupportedError(DatabaseError):
|
||||
|
||||
"""Exception raised in case a method or database API was used
|
||||
which is not supported by the database, e.g. requesting a
|
||||
.rollback() on a connection that does not support transaction or
|
||||
has transactions turned off."""
|
||||
|
||||
|
||||
"""_mysql_exceptions: Exception classes for _mysql and MySQLdb.
|
||||
|
||||
These classes are dictated by the DB API v2.0:
|
||||
|
||||
http://www.python.org/topics/database/DatabaseAPI-2.0.html
|
||||
"""
|
||||
|
||||
try:
|
||||
from exceptions import Exception, StandardError, Warning
|
||||
except ImportError:
|
||||
# Python 3
|
||||
StandardError = Exception
|
||||
|
||||
|
||||
class MySQLError(StandardError):
|
||||
|
||||
"""Exception related to operation with MySQL."""
|
||||
|
||||
|
||||
class Warning(Warning, MySQLError):
|
||||
|
||||
"""Exception raised for important warnings like data truncations
|
||||
while inserting, etc."""
|
||||
|
||||
class Error(MySQLError):
|
||||
|
||||
"""Exception that is the base class of all other error exceptions
|
||||
(not Warning)."""
|
||||
|
||||
|
||||
class InterfaceError(Error):
|
||||
|
||||
"""Exception raised for errors that are related to the database
|
||||
interface rather than the database itself."""
|
||||
|
||||
|
||||
class DatabaseError(Error):
|
||||
|
||||
"""Exception raised for errors that are related to the
|
||||
database."""
|
||||
|
||||
|
||||
class DataError(DatabaseError):
|
||||
|
||||
"""Exception raised for errors that are due to problems with the
|
||||
processed data like division by zero, numeric value out of range,
|
||||
etc."""
|
||||
|
||||
|
||||
class OperationalError(DatabaseError):
|
||||
|
||||
"""Exception raised for errors that are related to the database's
|
||||
operation and not necessarily under the control of the programmer,
|
||||
e.g. an unexpected disconnect occurs, the data source name is not
|
||||
found, a transaction could not be processed, a memory allocation
|
||||
error occurred during processing, etc."""
|
||||
|
||||
|
||||
class IntegrityError(DatabaseError):
|
||||
|
||||
"""Exception raised when the relational integrity of the database
|
||||
is affected, e.g. a foreign key check fails, duplicate key,
|
||||
etc."""
|
||||
|
||||
|
||||
class InternalError(DatabaseError):
|
||||
|
||||
"""Exception raised when the database encounters an internal
|
||||
error, e.g. the cursor is not valid anymore, the transaction is
|
||||
out of sync, etc."""
|
||||
|
||||
|
||||
class ProgrammingError(DatabaseError):
|
||||
|
||||
"""Exception raised for programming errors, e.g. table not found
|
||||
or already exists, syntax error in the SQL statement, wrong number
|
||||
of parameters specified, etc."""
|
||||
|
||||
|
||||
class NotSupportedError(DatabaseError):
|
||||
|
||||
"""Exception raised in case a method or database API was used
|
||||
which is not supported by the database, e.g. requesting a
|
||||
.rollback() on a connection that does not support transaction or
|
||||
has transactions turned off."""
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,143 +1,143 @@
|
||||
====================================
|
||||
MySQLdb Frequently Asked Questions
|
||||
====================================
|
||||
|
||||
.. contents::
|
||||
..
|
||||
|
||||
|
||||
Build Errors
|
||||
------------
|
||||
|
||||
ld: fatal: library -lmysqlclient_r: not found
|
||||
|
||||
mysqlclient_r is the thread-safe library. It's not available on
|
||||
all platforms, or all installations, apparently. You'll need to
|
||||
reconfigure site.cfg (in MySQLdb-1.2.1 and newer) to have
|
||||
threadsafe = False.
|
||||
|
||||
mysql.h: No such file or directory
|
||||
|
||||
This almost always mean you don't have development packages
|
||||
installed. On some systems, C headers for various things (like MySQL)
|
||||
are distributed as a seperate package. You'll need to figure out
|
||||
what that is and install it, but often the name ends with -devel.
|
||||
|
||||
Another possibility: Some older versions of mysql_config behave oddly
|
||||
and may throw quotes around some of the path names, which confused
|
||||
MySQLdb-1.2.0. 1.2.1 works around these problems. If you see things
|
||||
like -I'/usr/local/include/mysql' in your compile command, that's
|
||||
probably the issue, but it shouldn't happen any more.
|
||||
|
||||
|
||||
ImportError
|
||||
-----------
|
||||
|
||||
ImportError: No module named _mysql
|
||||
|
||||
If you see this, it's likely you did some wrong when installing
|
||||
MySQLdb; re-read (or read) README. _mysql is the low-level C module
|
||||
that interfaces with the MySQL client library.
|
||||
|
||||
Various versions of MySQLdb in the past have had build issues on
|
||||
"weird" platforms; "weird" in this case means "not Linux", though
|
||||
generally there aren't problems on Unix/POSIX platforms, including
|
||||
BSDs and Mac OS X. Windows has been more problematic, in part because
|
||||
there is no `mysql_config` available in the Windows installation of
|
||||
MySQL. 1.2.1 solves most, if not all, of these problems, but you will
|
||||
still have to edit a configuration file so that the setup knows where
|
||||
to find MySQL and what libraries to include.
|
||||
|
||||
|
||||
ImportError: libmysqlclient_r.so.14: cannot open shared object file: No such file or directory
|
||||
|
||||
The number after .so may vary, but this means you have a version of
|
||||
MySQLdb compiled against one version of MySQL, and are now trying to
|
||||
run it against a different version. The shared library version tends
|
||||
to change between major releases.
|
||||
|
||||
Solution: Rebuilt MySQLdb, or get the matching version of MySQL.
|
||||
|
||||
Another thing that can cause this: The MySQL libraries may not be on
|
||||
your system path.
|
||||
|
||||
Solutions:
|
||||
|
||||
* set the LD_LIBRARY_PATH environment variable so that it includes
|
||||
the path to the MySQL libraries.
|
||||
|
||||
* set static=True in site.cfg for static linking
|
||||
|
||||
* reconfigure your system so that the MySQL libraries are on the
|
||||
default loader path. In Linux, you edit /etc/ld.so.conf and run
|
||||
ldconfig. For Solaris, see `Linker and Libraries Guide
|
||||
<http://docs.sun.com/app/docs/doc/817-3677/6mj8mbtbe?a=view>`_.
|
||||
|
||||
|
||||
ImportError: ld.so.1: python: fatal: libmtmalloc.so.1: DF_1_NOOPEN tagged object may not be dlopen()'ed
|
||||
|
||||
This is a weird one from Solaris. What does it mean? I have no idea.
|
||||
However, things like this can happen if there is some sort of a compiler
|
||||
or environment mismatch between Python and MySQL. For example, on some
|
||||
commercial systems, you might have some code compiled with their own
|
||||
compiler, and other things compiled with GCC. They don't always mesh
|
||||
together. One way to encounter this is by getting binary packages from
|
||||
different vendors.
|
||||
|
||||
Solution: Rebuild Python or MySQL (or maybe both) from source.
|
||||
|
||||
ImportError: dlopen(./_mysql.so, 2): Symbol not found: _sprintf$LDBLStub
|
||||
Referenced from: ./_mysql.so
|
||||
Expected in: dynamic lookup
|
||||
|
||||
This is one from Mac OS X. It seems to have been a compiler mismatch,
|
||||
but this time between two different versions of GCC. It seems nearly
|
||||
every major release of GCC changes the ABI in some why, so linking
|
||||
code compiled with GCC-3.3 and GCC-4.0, for example, can be
|
||||
problematic.
|
||||
|
||||
|
||||
My data disappeared! (or won't go away!)
|
||||
----------------------------------------
|
||||
|
||||
Starting with 1.2.0, MySQLdb disables autocommit by default, as
|
||||
required by the DB-API standard (`PEP-249`_). If you are using InnoDB
|
||||
tables or some other type of transactional table type, you'll need
|
||||
to do connection.commit() before closing the connection, or else
|
||||
none of your changes will be written to the database.
|
||||
|
||||
Conversely, you can also use connection.rollback() to throw away
|
||||
any changes you've made since the last commit.
|
||||
|
||||
Important note: Some SQL statements -- specifically DDL statements
|
||||
like CREATE TABLE -- are non-transactional, so they can't be
|
||||
rolled back, and they cause pending transactions to commit.
|
||||
|
||||
|
||||
Other Errors
|
||||
------------
|
||||
|
||||
OperationalError: (1251, 'Client does not support authentication protocol requested by server; consider upgrading MySQL client')
|
||||
|
||||
This means your server and client libraries are not the same version.
|
||||
More specifically, it probably means you have a 4.1 or newer server
|
||||
and 4.0 or older client. You can either upgrade the client side, or
|
||||
try some of the workarounds in `Password Hashing as of MySQL 4.1
|
||||
<http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html>`_.
|
||||
|
||||
|
||||
Other Resources
|
||||
---------------
|
||||
|
||||
* Help forum. Please search before posting.
|
||||
|
||||
* `Google <http://www.google.com/>`_
|
||||
|
||||
* READ README!
|
||||
|
||||
* Read the User's Guide
|
||||
|
||||
* Read `PEP-249`_
|
||||
|
||||
.. _`PEP-249`: http://www.python.org/peps/pep-0249.html
|
||||
|
||||
====================================
|
||||
MySQLdb Frequently Asked Questions
|
||||
====================================
|
||||
|
||||
.. contents::
|
||||
..
|
||||
|
||||
|
||||
Build Errors
|
||||
------------
|
||||
|
||||
ld: fatal: library -lmysqlclient_r: not found
|
||||
|
||||
mysqlclient_r is the thread-safe library. It's not available on
|
||||
all platforms, or all installations, apparently. You'll need to
|
||||
reconfigure site.cfg (in MySQLdb-1.2.1 and newer) to have
|
||||
threadsafe = False.
|
||||
|
||||
mysql.h: No such file or directory
|
||||
|
||||
This almost always mean you don't have development packages
|
||||
installed. On some systems, C headers for various things (like MySQL)
|
||||
are distributed as a seperate package. You'll need to figure out
|
||||
what that is and install it, but often the name ends with -devel.
|
||||
|
||||
Another possibility: Some older versions of mysql_config behave oddly
|
||||
and may throw quotes around some of the path names, which confused
|
||||
MySQLdb-1.2.0. 1.2.1 works around these problems. If you see things
|
||||
like -I'/usr/local/include/mysql' in your compile command, that's
|
||||
probably the issue, but it shouldn't happen any more.
|
||||
|
||||
|
||||
ImportError
|
||||
-----------
|
||||
|
||||
ImportError: No module named _mysql
|
||||
|
||||
If you see this, it's likely you did some wrong when installing
|
||||
MySQLdb; re-read (or read) README. _mysql is the low-level C module
|
||||
that interfaces with the MySQL client library.
|
||||
|
||||
Various versions of MySQLdb in the past have had build issues on
|
||||
"weird" platforms; "weird" in this case means "not Linux", though
|
||||
generally there aren't problems on Unix/POSIX platforms, including
|
||||
BSDs and Mac OS X. Windows has been more problematic, in part because
|
||||
there is no `mysql_config` available in the Windows installation of
|
||||
MySQL. 1.2.1 solves most, if not all, of these problems, but you will
|
||||
still have to edit a configuration file so that the setup knows where
|
||||
to find MySQL and what libraries to include.
|
||||
|
||||
|
||||
ImportError: libmysqlclient_r.so.14: cannot open shared object file: No such file or directory
|
||||
|
||||
The number after .so may vary, but this means you have a version of
|
||||
MySQLdb compiled against one version of MySQL, and are now trying to
|
||||
run it against a different version. The shared library version tends
|
||||
to change between major releases.
|
||||
|
||||
Solution: Rebuilt MySQLdb, or get the matching version of MySQL.
|
||||
|
||||
Another thing that can cause this: The MySQL libraries may not be on
|
||||
your system path.
|
||||
|
||||
Solutions:
|
||||
|
||||
* set the LD_LIBRARY_PATH environment variable so that it includes
|
||||
the path to the MySQL libraries.
|
||||
|
||||
* set static=True in site.cfg for static linking
|
||||
|
||||
* reconfigure your system so that the MySQL libraries are on the
|
||||
default loader path. In Linux, you edit /etc/ld.so.conf and run
|
||||
ldconfig. For Solaris, see `Linker and Libraries Guide
|
||||
<http://docs.sun.com/app/docs/doc/817-3677/6mj8mbtbe?a=view>`_.
|
||||
|
||||
|
||||
ImportError: ld.so.1: python: fatal: libmtmalloc.so.1: DF_1_NOOPEN tagged object may not be dlopen()'ed
|
||||
|
||||
This is a weird one from Solaris. What does it mean? I have no idea.
|
||||
However, things like this can happen if there is some sort of a compiler
|
||||
or environment mismatch between Python and MySQL. For example, on some
|
||||
commercial systems, you might have some code compiled with their own
|
||||
compiler, and other things compiled with GCC. They don't always mesh
|
||||
together. One way to encounter this is by getting binary packages from
|
||||
different vendors.
|
||||
|
||||
Solution: Rebuild Python or MySQL (or maybe both) from source.
|
||||
|
||||
ImportError: dlopen(./_mysql.so, 2): Symbol not found: _sprintf$LDBLStub
|
||||
Referenced from: ./_mysql.so
|
||||
Expected in: dynamic lookup
|
||||
|
||||
This is one from Mac OS X. It seems to have been a compiler mismatch,
|
||||
but this time between two different versions of GCC. It seems nearly
|
||||
every major release of GCC changes the ABI in some why, so linking
|
||||
code compiled with GCC-3.3 and GCC-4.0, for example, can be
|
||||
problematic.
|
||||
|
||||
|
||||
My data disappeared! (or won't go away!)
|
||||
----------------------------------------
|
||||
|
||||
Starting with 1.2.0, MySQLdb disables autocommit by default, as
|
||||
required by the DB-API standard (`PEP-249`_). If you are using InnoDB
|
||||
tables or some other type of transactional table type, you'll need
|
||||
to do connection.commit() before closing the connection, or else
|
||||
none of your changes will be written to the database.
|
||||
|
||||
Conversely, you can also use connection.rollback() to throw away
|
||||
any changes you've made since the last commit.
|
||||
|
||||
Important note: Some SQL statements -- specifically DDL statements
|
||||
like CREATE TABLE -- are non-transactional, so they can't be
|
||||
rolled back, and they cause pending transactions to commit.
|
||||
|
||||
|
||||
Other Errors
|
||||
------------
|
||||
|
||||
OperationalError: (1251, 'Client does not support authentication protocol requested by server; consider upgrading MySQL client')
|
||||
|
||||
This means your server and client libraries are not the same version.
|
||||
More specifically, it probably means you have a 4.1 or newer server
|
||||
and 4.0 or older client. You can either upgrade the client side, or
|
||||
try some of the workarounds in `Password Hashing as of MySQL 4.1
|
||||
<http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html>`_.
|
||||
|
||||
|
||||
Other Resources
|
||||
---------------
|
||||
|
||||
* Help forum. Please search before posting.
|
||||
|
||||
* `Google <http://www.google.com/>`_
|
||||
|
||||
* READ README!
|
||||
|
||||
* Read the User's Guide
|
||||
|
||||
* Read `PEP-249`_
|
||||
|
||||
.. _`PEP-249`: http://www.python.org/peps/pep-0249.html
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,284 +1,284 @@
|
||||
#!python
|
||||
"""Bootstrap setuptools installation
|
||||
|
||||
If you want to use setuptools in your package's setup.py, just include this
|
||||
file in the same directory with it, and add this to the top of your setup.py::
|
||||
|
||||
from ez_setup import use_setuptools
|
||||
use_setuptools()
|
||||
|
||||
If you want to require a specific version of setuptools, set a download
|
||||
mirror, or use an alternate download directory, you can do so by supplying
|
||||
the appropriate options to ``use_setuptools()``.
|
||||
|
||||
This file can also be run as a script to install or upgrade setuptools.
|
||||
"""
|
||||
import sys
|
||||
DEFAULT_VERSION = "0.6c11"
|
||||
DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
|
||||
|
||||
md5_data = {
|
||||
'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
|
||||
'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
|
||||
'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
|
||||
'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
|
||||
'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
|
||||
'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
|
||||
'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
|
||||
'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
|
||||
'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
|
||||
'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
|
||||
'setuptools-0.6c10-py2.3.egg': 'ce1e2ab5d3a0256456d9fc13800a7090',
|
||||
'setuptools-0.6c10-py2.4.egg': '57d6d9d6e9b80772c59a53a8433a5dd4',
|
||||
'setuptools-0.6c10-py2.5.egg': 'de46ac8b1c97c895572e5e8596aeb8c7',
|
||||
'setuptools-0.6c10-py2.6.egg': '58ea40aef06da02ce641495523a0b7f5',
|
||||
'setuptools-0.6c11-py2.3.egg': '2baeac6e13d414a9d28e7ba5b5a596de',
|
||||
'setuptools-0.6c11-py2.4.egg': 'bd639f9b0eac4c42497034dec2ec0c2b',
|
||||
'setuptools-0.6c11-py2.5.egg': '64c94f3bf7a72a13ec83e0b24f2749b2',
|
||||
'setuptools-0.6c11-py2.6.egg': 'bfa92100bd772d5a213eedd356d64086',
|
||||
'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
|
||||
'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
|
||||
'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
|
||||
'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
|
||||
'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
|
||||
'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
|
||||
'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
|
||||
'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
|
||||
'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
|
||||
'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
|
||||
'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
|
||||
'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
|
||||
'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
|
||||
'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
|
||||
'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
|
||||
'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
|
||||
'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
|
||||
'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
|
||||
'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
|
||||
'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
|
||||
'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03',
|
||||
'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a',
|
||||
'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6',
|
||||
'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a',
|
||||
}
|
||||
|
||||
import sys, os
|
||||
try: from hashlib import md5
|
||||
except ImportError: from md5 import md5
|
||||
|
||||
def _validate_md5(egg_name, data):
|
||||
if egg_name in md5_data:
|
||||
digest = md5(data).hexdigest()
|
||||
if digest != md5_data[egg_name]:
|
||||
print >>sys.stderr, (
|
||||
"md5 validation of %s failed! (Possible download problem?)"
|
||||
% egg_name
|
||||
)
|
||||
sys.exit(2)
|
||||
return data
|
||||
|
||||
def use_setuptools(
|
||||
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
|
||||
download_delay=15
|
||||
):
|
||||
"""Automatically find/download setuptools and make it available on sys.path
|
||||
|
||||
`version` should be a valid setuptools version number that is available
|
||||
as an egg for download under the `download_base` URL (which should end with
|
||||
a '/'). `to_dir` is the directory where setuptools will be downloaded, if
|
||||
it is not already available. If `download_delay` is specified, it should
|
||||
be the number of seconds that will be paused before initiating a download,
|
||||
should one be required. If an older version of setuptools is installed,
|
||||
this routine will print a message to ``sys.stderr`` and raise SystemExit in
|
||||
an attempt to abort the calling script.
|
||||
"""
|
||||
was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
|
||||
def do_download():
|
||||
egg = download_setuptools(version, download_base, to_dir, download_delay)
|
||||
sys.path.insert(0, egg)
|
||||
import setuptools; setuptools.bootstrap_install_from = egg
|
||||
try:
|
||||
import pkg_resources
|
||||
except ImportError:
|
||||
return do_download()
|
||||
try:
|
||||
pkg_resources.require("setuptools>="+version); return
|
||||
except pkg_resources.VersionConflict, e:
|
||||
if was_imported:
|
||||
print >>sys.stderr, (
|
||||
"The required version of setuptools (>=%s) is not available, and\n"
|
||||
"can't be installed while this script is running. Please install\n"
|
||||
" a more recent version first, using 'easy_install -U setuptools'."
|
||||
"\n\n(Currently using %r)"
|
||||
) % (version, e.args[0])
|
||||
sys.exit(2)
|
||||
else:
|
||||
del pkg_resources, sys.modules['pkg_resources'] # reload ok
|
||||
return do_download()
|
||||
except pkg_resources.DistributionNotFound:
|
||||
return do_download()
|
||||
|
||||
def download_setuptools(
|
||||
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
|
||||
delay = 15
|
||||
):
|
||||
"""Download setuptools from a specified location and return its filename
|
||||
|
||||
`version` should be a valid setuptools version number that is available
|
||||
as an egg for download under the `download_base` URL (which should end
|
||||
with a '/'). `to_dir` is the directory where the egg will be downloaded.
|
||||
`delay` is the number of seconds to pause before an actual download attempt.
|
||||
"""
|
||||
import urllib2, shutil
|
||||
egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
|
||||
url = download_base + egg_name
|
||||
saveto = os.path.join(to_dir, egg_name)
|
||||
src = dst = None
|
||||
if not os.path.exists(saveto): # Avoid repeated downloads
|
||||
try:
|
||||
from distutils import log
|
||||
if delay:
|
||||
log.warn("""
|
||||
---------------------------------------------------------------------------
|
||||
This script requires setuptools version %s to run (even to display
|
||||
help). I will attempt to download it for you (from
|
||||
%s), but
|
||||
you may need to enable firewall access for this script first.
|
||||
I will start the download in %d seconds.
|
||||
|
||||
(Note: if this machine does not have network access, please obtain the file
|
||||
|
||||
%s
|
||||
|
||||
and place it in this directory before rerunning this script.)
|
||||
---------------------------------------------------------------------------""",
|
||||
version, download_base, delay, url
|
||||
); from time import sleep; sleep(delay)
|
||||
log.warn("Downloading %s", url)
|
||||
src = urllib2.urlopen(url)
|
||||
# Read/write all in one block, so we don't create a corrupt file
|
||||
# if the download is interrupted.
|
||||
data = _validate_md5(egg_name, src.read())
|
||||
dst = open(saveto,"wb"); dst.write(data)
|
||||
finally:
|
||||
if src: src.close()
|
||||
if dst: dst.close()
|
||||
return os.path.realpath(saveto)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def main(argv, version=DEFAULT_VERSION):
|
||||
"""Install or upgrade setuptools and EasyInstall"""
|
||||
try:
|
||||
import setuptools
|
||||
except ImportError:
|
||||
egg = None
|
||||
try:
|
||||
egg = download_setuptools(version, delay=0)
|
||||
sys.path.insert(0,egg)
|
||||
from setuptools.command.easy_install import main
|
||||
return main(list(argv)+[egg]) # we're done here
|
||||
finally:
|
||||
if egg and os.path.exists(egg):
|
||||
os.unlink(egg)
|
||||
else:
|
||||
if setuptools.__version__ == '0.0.1':
|
||||
print >>sys.stderr, (
|
||||
"You have an obsolete version of setuptools installed. Please\n"
|
||||
"remove it from your system entirely before rerunning this script."
|
||||
)
|
||||
sys.exit(2)
|
||||
|
||||
req = "setuptools>="+version
|
||||
import pkg_resources
|
||||
try:
|
||||
pkg_resources.require(req)
|
||||
except pkg_resources.VersionConflict:
|
||||
try:
|
||||
from setuptools.command.easy_install import main
|
||||
except ImportError:
|
||||
from easy_install import main
|
||||
main(list(argv)+[download_setuptools(delay=0)])
|
||||
sys.exit(0) # try to force an exit
|
||||
else:
|
||||
if argv:
|
||||
from setuptools.command.easy_install import main
|
||||
main(argv)
|
||||
else:
|
||||
print "Setuptools version",version,"or greater has been installed."
|
||||
print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
|
||||
|
||||
def update_md5(filenames):
|
||||
"""Update our built-in md5 registry"""
|
||||
|
||||
import re
|
||||
|
||||
for name in filenames:
|
||||
base = os.path.basename(name)
|
||||
f = open(name,'rb')
|
||||
md5_data[base] = md5(f.read()).hexdigest()
|
||||
f.close()
|
||||
|
||||
data = [" %r: %r,\n" % it for it in md5_data.items()]
|
||||
data.sort()
|
||||
repl = "".join(data)
|
||||
|
||||
import inspect
|
||||
srcfile = inspect.getsourcefile(sys.modules[__name__])
|
||||
f = open(srcfile, 'rb'); src = f.read(); f.close()
|
||||
|
||||
match = re.search("\nmd5_data = {\n([^}]+)}", src)
|
||||
if not match:
|
||||
print >>sys.stderr, "Internal error!"
|
||||
sys.exit(2)
|
||||
|
||||
src = src[:match.start(1)] + repl + src[match.end(1):]
|
||||
f = open(srcfile,'w')
|
||||
f.write(src)
|
||||
f.close()
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
if len(sys.argv)>2 and sys.argv[1]=='--md5update':
|
||||
update_md5(sys.argv[2:])
|
||||
else:
|
||||
main(sys.argv[1:])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#!python
|
||||
"""Bootstrap setuptools installation
|
||||
|
||||
If you want to use setuptools in your package's setup.py, just include this
|
||||
file in the same directory with it, and add this to the top of your setup.py::
|
||||
|
||||
from ez_setup import use_setuptools
|
||||
use_setuptools()
|
||||
|
||||
If you want to require a specific version of setuptools, set a download
|
||||
mirror, or use an alternate download directory, you can do so by supplying
|
||||
the appropriate options to ``use_setuptools()``.
|
||||
|
||||
This file can also be run as a script to install or upgrade setuptools.
|
||||
"""
|
||||
import sys
|
||||
DEFAULT_VERSION = "0.6c11"
|
||||
DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
|
||||
|
||||
md5_data = {
|
||||
'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
|
||||
'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
|
||||
'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
|
||||
'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
|
||||
'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
|
||||
'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
|
||||
'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
|
||||
'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
|
||||
'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
|
||||
'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
|
||||
'setuptools-0.6c10-py2.3.egg': 'ce1e2ab5d3a0256456d9fc13800a7090',
|
||||
'setuptools-0.6c10-py2.4.egg': '57d6d9d6e9b80772c59a53a8433a5dd4',
|
||||
'setuptools-0.6c10-py2.5.egg': 'de46ac8b1c97c895572e5e8596aeb8c7',
|
||||
'setuptools-0.6c10-py2.6.egg': '58ea40aef06da02ce641495523a0b7f5',
|
||||
'setuptools-0.6c11-py2.3.egg': '2baeac6e13d414a9d28e7ba5b5a596de',
|
||||
'setuptools-0.6c11-py2.4.egg': 'bd639f9b0eac4c42497034dec2ec0c2b',
|
||||
'setuptools-0.6c11-py2.5.egg': '64c94f3bf7a72a13ec83e0b24f2749b2',
|
||||
'setuptools-0.6c11-py2.6.egg': 'bfa92100bd772d5a213eedd356d64086',
|
||||
'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
|
||||
'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
|
||||
'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
|
||||
'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
|
||||
'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
|
||||
'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
|
||||
'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
|
||||
'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
|
||||
'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
|
||||
'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
|
||||
'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
|
||||
'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
|
||||
'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
|
||||
'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
|
||||
'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
|
||||
'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
|
||||
'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
|
||||
'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
|
||||
'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
|
||||
'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
|
||||
'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03',
|
||||
'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a',
|
||||
'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6',
|
||||
'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a',
|
||||
}
|
||||
|
||||
import sys, os
|
||||
try: from hashlib import md5
|
||||
except ImportError: from md5 import md5
|
||||
|
||||
def _validate_md5(egg_name, data):
|
||||
if egg_name in md5_data:
|
||||
digest = md5(data).hexdigest()
|
||||
if digest != md5_data[egg_name]:
|
||||
print >>sys.stderr, (
|
||||
"md5 validation of %s failed! (Possible download problem?)"
|
||||
% egg_name
|
||||
)
|
||||
sys.exit(2)
|
||||
return data
|
||||
|
||||
def use_setuptools(
|
||||
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
|
||||
download_delay=15
|
||||
):
|
||||
"""Automatically find/download setuptools and make it available on sys.path
|
||||
|
||||
`version` should be a valid setuptools version number that is available
|
||||
as an egg for download under the `download_base` URL (which should end with
|
||||
a '/'). `to_dir` is the directory where setuptools will be downloaded, if
|
||||
it is not already available. If `download_delay` is specified, it should
|
||||
be the number of seconds that will be paused before initiating a download,
|
||||
should one be required. If an older version of setuptools is installed,
|
||||
this routine will print a message to ``sys.stderr`` and raise SystemExit in
|
||||
an attempt to abort the calling script.
|
||||
"""
|
||||
was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
|
||||
def do_download():
|
||||
egg = download_setuptools(version, download_base, to_dir, download_delay)
|
||||
sys.path.insert(0, egg)
|
||||
import setuptools; setuptools.bootstrap_install_from = egg
|
||||
try:
|
||||
import pkg_resources
|
||||
except ImportError:
|
||||
return do_download()
|
||||
try:
|
||||
pkg_resources.require("setuptools>="+version); return
|
||||
except pkg_resources.VersionConflict, e:
|
||||
if was_imported:
|
||||
print >>sys.stderr, (
|
||||
"The required version of setuptools (>=%s) is not available, and\n"
|
||||
"can't be installed while this script is running. Please install\n"
|
||||
" a more recent version first, using 'easy_install -U setuptools'."
|
||||
"\n\n(Currently using %r)"
|
||||
) % (version, e.args[0])
|
||||
sys.exit(2)
|
||||
else:
|
||||
del pkg_resources, sys.modules['pkg_resources'] # reload ok
|
||||
return do_download()
|
||||
except pkg_resources.DistributionNotFound:
|
||||
return do_download()
|
||||
|
||||
def download_setuptools(
|
||||
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
|
||||
delay = 15
|
||||
):
|
||||
"""Download setuptools from a specified location and return its filename
|
||||
|
||||
`version` should be a valid setuptools version number that is available
|
||||
as an egg for download under the `download_base` URL (which should end
|
||||
with a '/'). `to_dir` is the directory where the egg will be downloaded.
|
||||
`delay` is the number of seconds to pause before an actual download attempt.
|
||||
"""
|
||||
import urllib2, shutil
|
||||
egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
|
||||
url = download_base + egg_name
|
||||
saveto = os.path.join(to_dir, egg_name)
|
||||
src = dst = None
|
||||
if not os.path.exists(saveto): # Avoid repeated downloads
|
||||
try:
|
||||
from distutils import log
|
||||
if delay:
|
||||
log.warn("""
|
||||
---------------------------------------------------------------------------
|
||||
This script requires setuptools version %s to run (even to display
|
||||
help). I will attempt to download it for you (from
|
||||
%s), but
|
||||
you may need to enable firewall access for this script first.
|
||||
I will start the download in %d seconds.
|
||||
|
||||
(Note: if this machine does not have network access, please obtain the file
|
||||
|
||||
%s
|
||||
|
||||
and place it in this directory before rerunning this script.)
|
||||
---------------------------------------------------------------------------""",
|
||||
version, download_base, delay, url
|
||||
); from time import sleep; sleep(delay)
|
||||
log.warn("Downloading %s", url)
|
||||
src = urllib2.urlopen(url)
|
||||
# Read/write all in one block, so we don't create a corrupt file
|
||||
# if the download is interrupted.
|
||||
data = _validate_md5(egg_name, src.read())
|
||||
dst = open(saveto,"wb"); dst.write(data)
|
||||
finally:
|
||||
if src: src.close()
|
||||
if dst: dst.close()
|
||||
return os.path.realpath(saveto)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def main(argv, version=DEFAULT_VERSION):
|
||||
"""Install or upgrade setuptools and EasyInstall"""
|
||||
try:
|
||||
import setuptools
|
||||
except ImportError:
|
||||
egg = None
|
||||
try:
|
||||
egg = download_setuptools(version, delay=0)
|
||||
sys.path.insert(0,egg)
|
||||
from setuptools.command.easy_install import main
|
||||
return main(list(argv)+[egg]) # we're done here
|
||||
finally:
|
||||
if egg and os.path.exists(egg):
|
||||
os.unlink(egg)
|
||||
else:
|
||||
if setuptools.__version__ == '0.0.1':
|
||||
print >>sys.stderr, (
|
||||
"You have an obsolete version of setuptools installed. Please\n"
|
||||
"remove it from your system entirely before rerunning this script."
|
||||
)
|
||||
sys.exit(2)
|
||||
|
||||
req = "setuptools>="+version
|
||||
import pkg_resources
|
||||
try:
|
||||
pkg_resources.require(req)
|
||||
except pkg_resources.VersionConflict:
|
||||
try:
|
||||
from setuptools.command.easy_install import main
|
||||
except ImportError:
|
||||
from easy_install import main
|
||||
main(list(argv)+[download_setuptools(delay=0)])
|
||||
sys.exit(0) # try to force an exit
|
||||
else:
|
||||
if argv:
|
||||
from setuptools.command.easy_install import main
|
||||
main(argv)
|
||||
else:
|
||||
print "Setuptools version",version,"or greater has been installed."
|
||||
print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
|
||||
|
||||
def update_md5(filenames):
|
||||
"""Update our built-in md5 registry"""
|
||||
|
||||
import re
|
||||
|
||||
for name in filenames:
|
||||
base = os.path.basename(name)
|
||||
f = open(name,'rb')
|
||||
md5_data[base] = md5(f.read()).hexdigest()
|
||||
f.close()
|
||||
|
||||
data = [" %r: %r,\n" % it for it in md5_data.items()]
|
||||
data.sort()
|
||||
repl = "".join(data)
|
||||
|
||||
import inspect
|
||||
srcfile = inspect.getsourcefile(sys.modules[__name__])
|
||||
f = open(srcfile, 'rb'); src = f.read(); f.close()
|
||||
|
||||
match = re.search("\nmd5_data = {\n([^}]+)}", src)
|
||||
if not match:
|
||||
print >>sys.stderr, "Internal error!"
|
||||
sys.exit(2)
|
||||
|
||||
src = src[:match.start(1)] + repl + src[match.end(1):]
|
||||
f = open(srcfile,'w')
|
||||
f.write(src)
|
||||
f.close()
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
if len(sys.argv)>2 and sys.argv[1]=='--md5update':
|
||||
update_md5(sys.argv[2:])
|
||||
else:
|
||||
main(sys.argv[1:])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,87 +1,87 @@
|
||||
|
||||
/* The idea of this file is that you bundle it with your extension,
|
||||
#include it, program to Python 2.3's memory API and have your
|
||||
extension build with any version of Python from 1.5.2 through to
|
||||
2.3 (and hopefully beyond). */
|
||||
|
||||
#ifndef Py_PYMEMCOMPAT_H
|
||||
#define Py_PYMEMCOMPAT_H
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
/* There are three "families" of memory API: the "raw memory", "object
|
||||
memory" and "object" families. (This is ignoring the matter of the
|
||||
cycle collector, about which more is said below).
|
||||
|
||||
Raw Memory:
|
||||
|
||||
PyMem_Malloc, PyMem_Realloc, PyMem_Free
|
||||
|
||||
Object Memory:
|
||||
|
||||
PyObject_Malloc, PyObject_Realloc, PyObject_Free
|
||||
|
||||
Object:
|
||||
|
||||
PyObject_New, PyObject_NewVar, PyObject_Del
|
||||
|
||||
The raw memory and object memory allocators both mimic the
|
||||
malloc/realloc/free interface from ANSI C, but the object memory
|
||||
allocator can (and, since 2.3, does by default) use a different
|
||||
allocation strategy biased towards lots of lots of "small"
|
||||
allocations.
|
||||
|
||||
The object family is used for allocating Python objects, and the
|
||||
initializers take care of some basic initialization (setting the
|
||||
refcount to 1 and filling out the ob_type field) as well as having
|
||||
a somewhat different interface.
|
||||
|
||||
Do not mix the families! E.g. do not allocate memory with
|
||||
PyMem_Malloc and free it with PyObject_Free. You may get away with
|
||||
it quite a lot of the time, but there *are* scenarios where this
|
||||
will break. You Have Been Warned.
|
||||
|
||||
Also, in many versions of Python there are an insane amount of
|
||||
memory interfaces to choose from. Use the ones described above. */
|
||||
|
||||
#if PY_VERSION_HEX < 0x01060000
|
||||
/* raw memory interface already present */
|
||||
|
||||
/* there is no object memory interface in 1.5.2 */
|
||||
#define PyObject_Malloc PyMem_Malloc
|
||||
#define PyObject_Realloc PyMem_Realloc
|
||||
#define PyObject_Free PyMem_Free
|
||||
|
||||
/* the object interface is there, but the names have changed */
|
||||
#define PyObject_New PyObject_NEW
|
||||
#define PyObject_NewVar PyObject_NEW_VAR
|
||||
#define PyObject_Del PyMem_Free
|
||||
#endif
|
||||
|
||||
/* If your object is a container you probably want to support the
|
||||
cycle collector, which was new in Python 2.0.
|
||||
|
||||
Unfortunately, the interface to the collector that was present in
|
||||
Python 2.0 and 2.1 proved to be tricky to use, and so changed in
|
||||
2.2 -- in a way that can't easily be papered over with macros.
|
||||
|
||||
This file contains macros that let you program to the 2.2 GC API.
|
||||
Your module will compile against any Python since version 1.5.2,
|
||||
but the type will only participate in the GC in versions 2.2 and
|
||||
up. Some work is still necessary on your part to only fill out the
|
||||
tp_traverse and tp_clear fields when they exist and set tp_flags
|
||||
appropriately.
|
||||
|
||||
It is possible to support both the 2.0 and 2.2 GC APIs, but it's
|
||||
not pretty and this comment block is too narrow to contain a
|
||||
desciption of what's required... */
|
||||
|
||||
#if PY_VERSION_HEX < 0x020200B1
|
||||
#define PyObject_GC_New PyObject_New
|
||||
#define PyObject_GC_NewVar PyObject_NewVar
|
||||
#define PyObject_GC_Del PyObject_Del
|
||||
#define PyObject_GC_Track(op)
|
||||
#define PyObject_GC_UnTrack(op)
|
||||
#endif
|
||||
|
||||
#endif /* !Py_PYMEMCOMPAT_H */
|
||||
|
||||
/* The idea of this file is that you bundle it with your extension,
|
||||
#include it, program to Python 2.3's memory API and have your
|
||||
extension build with any version of Python from 1.5.2 through to
|
||||
2.3 (and hopefully beyond). */
|
||||
|
||||
#ifndef Py_PYMEMCOMPAT_H
|
||||
#define Py_PYMEMCOMPAT_H
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
/* There are three "families" of memory API: the "raw memory", "object
|
||||
memory" and "object" families. (This is ignoring the matter of the
|
||||
cycle collector, about which more is said below).
|
||||
|
||||
Raw Memory:
|
||||
|
||||
PyMem_Malloc, PyMem_Realloc, PyMem_Free
|
||||
|
||||
Object Memory:
|
||||
|
||||
PyObject_Malloc, PyObject_Realloc, PyObject_Free
|
||||
|
||||
Object:
|
||||
|
||||
PyObject_New, PyObject_NewVar, PyObject_Del
|
||||
|
||||
The raw memory and object memory allocators both mimic the
|
||||
malloc/realloc/free interface from ANSI C, but the object memory
|
||||
allocator can (and, since 2.3, does by default) use a different
|
||||
allocation strategy biased towards lots of lots of "small"
|
||||
allocations.
|
||||
|
||||
The object family is used for allocating Python objects, and the
|
||||
initializers take care of some basic initialization (setting the
|
||||
refcount to 1 and filling out the ob_type field) as well as having
|
||||
a somewhat different interface.
|
||||
|
||||
Do not mix the families! E.g. do not allocate memory with
|
||||
PyMem_Malloc and free it with PyObject_Free. You may get away with
|
||||
it quite a lot of the time, but there *are* scenarios where this
|
||||
will break. You Have Been Warned.
|
||||
|
||||
Also, in many versions of Python there are an insane amount of
|
||||
memory interfaces to choose from. Use the ones described above. */
|
||||
|
||||
#if PY_VERSION_HEX < 0x01060000
|
||||
/* raw memory interface already present */
|
||||
|
||||
/* there is no object memory interface in 1.5.2 */
|
||||
#define PyObject_Malloc PyMem_Malloc
|
||||
#define PyObject_Realloc PyMem_Realloc
|
||||
#define PyObject_Free PyMem_Free
|
||||
|
||||
/* the object interface is there, but the names have changed */
|
||||
#define PyObject_New PyObject_NEW
|
||||
#define PyObject_NewVar PyObject_NEW_VAR
|
||||
#define PyObject_Del PyMem_Free
|
||||
#endif
|
||||
|
||||
/* If your object is a container you probably want to support the
|
||||
cycle collector, which was new in Python 2.0.
|
||||
|
||||
Unfortunately, the interface to the collector that was present in
|
||||
Python 2.0 and 2.1 proved to be tricky to use, and so changed in
|
||||
2.2 -- in a way that can't easily be papered over with macros.
|
||||
|
||||
This file contains macros that let you program to the 2.2 GC API.
|
||||
Your module will compile against any Python since version 1.5.2,
|
||||
but the type will only participate in the GC in versions 2.2 and
|
||||
up. Some work is still necessary on your part to only fill out the
|
||||
tp_traverse and tp_clear fields when they exist and set tp_flags
|
||||
appropriately.
|
||||
|
||||
It is possible to support both the 2.0 and 2.2 GC APIs, but it's
|
||||
not pretty and this comment block is too narrow to contain a
|
||||
desciption of what's required... */
|
||||
|
||||
#if PY_VERSION_HEX < 0x020200B1
|
||||
#define PyObject_GC_New PyObject_New
|
||||
#define PyObject_GC_NewVar PyObject_NewVar
|
||||
#define PyObject_GC_Del PyObject_Del
|
||||
#define PyObject_GC_Track(op)
|
||||
#define PyObject_GC_UnTrack(op)
|
||||
#endif
|
||||
|
||||
#endif /* !Py_PYMEMCOMPAT_H */
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
[test]
|
||||
test_suite = nose.collector
|
||||
|
||||
[build_ext]
|
||||
## Only uncomment/set these if the default configuration doesn't work
|
||||
## Also see http://docs.python.org/dist/setup-config.html
|
||||
# include-dirs = ?
|
||||
# library-dirs = ?
|
||||
# link-objects = ?
|
||||
# rpath = ?
|
||||
# libraries = ?
|
||||
|
||||
[bdist_rpm]
|
||||
doc_files = README MANIFEST doc/*.txt
|
||||
vendor = MySQL-python SourceForge Project
|
||||
packager = Andy Dustman <adustman@users.sourceforge.net>
|
||||
distribution-name = Red Stains Linux
|
||||
requires = python
|
||||
install-requires = distribute
|
||||
build-requires = python-devel mysql-devel zlib-devel openssl-devel
|
||||
[test]
|
||||
test_suite = nose.collector
|
||||
|
||||
[build_ext]
|
||||
## Only uncomment/set these if the default configuration doesn't work
|
||||
## Also see http://docs.python.org/dist/setup-config.html
|
||||
# include-dirs = ?
|
||||
# library-dirs = ?
|
||||
# link-objects = ?
|
||||
# rpath = ?
|
||||
# libraries = ?
|
||||
|
||||
[bdist_rpm]
|
||||
doc_files = README MANIFEST doc/*.txt
|
||||
vendor = MySQL-python SourceForge Project
|
||||
packager = Andy Dustman <adustman@users.sourceforge.net>
|
||||
distribution-name = Red Stains Linux
|
||||
requires = python
|
||||
install-requires = distribute
|
||||
build-requires = python-devel mysql-devel zlib-devel openssl-devel
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from distribute_setup import use_setuptools
|
||||
use_setuptools()
|
||||
from setuptools import setup, Extension
|
||||
|
||||
if not hasattr(sys, "hexversion") or sys.hexversion < 0x02040000:
|
||||
raise Error("Python 2.4 or newer is required")
|
||||
|
||||
if os.name == "posix":
|
||||
from setup_posix import get_config
|
||||
else: # assume windows
|
||||
from setup_windows import get_config
|
||||
|
||||
metadata, options = get_config()
|
||||
metadata['ext_modules'] = [Extension(sources=['_mysql.c'], **options)]
|
||||
metadata['long_description'] = metadata['long_description'].replace(r'\n', '')
|
||||
setup(**metadata)
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from distribute_setup import use_setuptools
|
||||
use_setuptools()
|
||||
from setuptools import setup, Extension
|
||||
|
||||
if not hasattr(sys, "hexversion") or sys.hexversion < 0x02040000:
|
||||
raise Error("Python 2.4 or newer is required")
|
||||
|
||||
if os.name == "posix":
|
||||
from setup_posix import get_config
|
||||
else: # assume windows
|
||||
from setup_windows import get_config
|
||||
|
||||
metadata, options = get_config()
|
||||
metadata['ext_modules'] = [Extension(sources=['_mysql.c'], **options)]
|
||||
metadata['long_description'] = metadata['long_description'].replace(r'\n', '')
|
||||
setup(**metadata)
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
try:
|
||||
# Python 2.x
|
||||
from ConfigParser import SafeConfigParser
|
||||
except ImportError:
|
||||
# Python 3.x
|
||||
from configparser import ConfigParser as SafeConfigParser
|
||||
|
||||
def get_metadata_and_options():
|
||||
config = SafeConfigParser()
|
||||
config.read(['metadata.cfg', 'site.cfg'])
|
||||
|
||||
metadata = dict(config.items('metadata'))
|
||||
options = dict(config.items('options'))
|
||||
|
||||
metadata['py_modules'] = list(filter(None, metadata['py_modules'].split('\n')))
|
||||
metadata['classifiers'] = list(filter(None, metadata['classifiers'].split('\n')))
|
||||
|
||||
return metadata, options
|
||||
|
||||
def enabled(options, option):
|
||||
value = options[option]
|
||||
s = value.lower()
|
||||
if s in ('yes','true','1','y'):
|
||||
return True
|
||||
elif s in ('no', 'false', '0', 'n'):
|
||||
return False
|
||||
else:
|
||||
raise ValueError("Unknown value %s for option %s" % (value, option))
|
||||
|
||||
def create_release_file(metadata):
|
||||
rel = open("MySQLdb/release.py",'w')
|
||||
rel.write("""
|
||||
__author__ = "%(author)s <%(author_email)s>"
|
||||
version_info = %(version_info)s
|
||||
__version__ = "%(version)s"
|
||||
""" % metadata)
|
||||
rel.close()
|
||||
try:
|
||||
# Python 2.x
|
||||
from ConfigParser import SafeConfigParser
|
||||
except ImportError:
|
||||
# Python 3.x
|
||||
from configparser import ConfigParser as SafeConfigParser
|
||||
|
||||
def get_metadata_and_options():
|
||||
config = SafeConfigParser()
|
||||
config.read(['metadata.cfg', 'site.cfg'])
|
||||
|
||||
metadata = dict(config.items('metadata'))
|
||||
options = dict(config.items('options'))
|
||||
|
||||
metadata['py_modules'] = list(filter(None, metadata['py_modules'].split('\n')))
|
||||
metadata['classifiers'] = list(filter(None, metadata['classifiers'].split('\n')))
|
||||
|
||||
return metadata, options
|
||||
|
||||
def enabled(options, option):
|
||||
value = options[option]
|
||||
s = value.lower()
|
||||
if s in ('yes','true','1','y'):
|
||||
return True
|
||||
elif s in ('no', 'false', '0', 'n'):
|
||||
return False
|
||||
else:
|
||||
raise ValueError("Unknown value %s for option %s" % (value, option))
|
||||
|
||||
def create_release_file(metadata):
|
||||
rel = open("MySQLdb/release.py",'w')
|
||||
rel.write("""
|
||||
__author__ = "%(author)s <%(author_email)s>"
|
||||
version_info = %(version_info)s
|
||||
__version__ = "%(version)s"
|
||||
""" % metadata)
|
||||
rel.close()
|
||||
|
||||
@@ -1,102 +1,102 @@
|
||||
import os, sys
|
||||
from ConfigParser import SafeConfigParser
|
||||
|
||||
# This dequote() business is required for some older versions
|
||||
# of mysql_config
|
||||
|
||||
def dequote(s):
|
||||
if s[0] in "\"'" and s[0] == s[-1]:
|
||||
s = s[1:-1]
|
||||
return s
|
||||
|
||||
def compiler_flag(f):
|
||||
return "-%s" % f
|
||||
|
||||
def mysql_config(what):
|
||||
from os import popen
|
||||
|
||||
f = popen("%s --%s" % (mysql_config.path, what))
|
||||
data = f.read().strip().split()
|
||||
ret = f.close()
|
||||
if ret:
|
||||
if ret/256:
|
||||
data = []
|
||||
if ret/256 > 1:
|
||||
raise EnvironmentError("%s not found" % (mysql_config.path,))
|
||||
return data
|
||||
mysql_config.path = "mysql_config"
|
||||
|
||||
def get_config():
|
||||
from setup_common import get_metadata_and_options, enabled, create_release_file
|
||||
|
||||
metadata, options = get_metadata_and_options()
|
||||
|
||||
if 'mysql_config' in options:
|
||||
mysql_config.path = options['mysql_config']
|
||||
|
||||
extra_objects = []
|
||||
static = enabled(options, 'static')
|
||||
if enabled(options, 'embedded'):
|
||||
libs = mysql_config("libmysqld-libs")
|
||||
client = "mysqld"
|
||||
elif enabled(options, 'threadsafe'):
|
||||
libs = mysql_config("libs_r")
|
||||
client = "mysqlclient_r"
|
||||
if not libs:
|
||||
libs = mysql_config("libs")
|
||||
client = "mysqlclient"
|
||||
else:
|
||||
libs = mysql_config("libs")
|
||||
client = "mysqlclient"
|
||||
|
||||
library_dirs = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("L")) ]
|
||||
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
|
||||
|
||||
removable_compile_args = [ compiler_flag(f) for f in "ILl" ]
|
||||
extra_compile_args = [ i.replace("%", "%%") for i in mysql_config("cflags")
|
||||
if i[:2] not in removable_compile_args ]
|
||||
|
||||
# Copy the arch flags for linking as well
|
||||
extra_link_args = list()
|
||||
for i in range(len(extra_compile_args)):
|
||||
if extra_compile_args[i] == '-arch':
|
||||
extra_link_args += ['-arch', extra_compile_args[i + 1]]
|
||||
|
||||
include_dirs = [ dequote(i[2:])
|
||||
for i in mysql_config('include')
|
||||
if i.startswith(compiler_flag('I')) ]
|
||||
if not include_dirs: # fix for MySQL-3.23
|
||||
include_dirs = [ dequote(i[2:])
|
||||
for i in mysql_config('cflags')
|
||||
if i.startswith(compiler_flag('I')) ]
|
||||
|
||||
if static:
|
||||
extra_objects.append(os.path.join(
|
||||
library_dirs[0],'lib%s.a' % client))
|
||||
|
||||
name = "MySQL-python"
|
||||
if enabled(options, 'embedded'):
|
||||
name = name + "-embedded"
|
||||
metadata['name'] = name
|
||||
|
||||
define_macros = [
|
||||
('version_info', metadata['version_info']),
|
||||
('__version__', metadata['version']),
|
||||
]
|
||||
create_release_file(metadata)
|
||||
del metadata['version_info']
|
||||
ext_options = dict(
|
||||
name = "_mysql",
|
||||
library_dirs = library_dirs,
|
||||
libraries = libraries,
|
||||
extra_compile_args = extra_compile_args,
|
||||
extra_link_args = extra_link_args,
|
||||
include_dirs = include_dirs,
|
||||
extra_objects = extra_objects,
|
||||
define_macros = define_macros,
|
||||
)
|
||||
return metadata, ext_options
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.stderr.write("""You shouldn't be running this directly; it is used by setup.py.""")
|
||||
|
||||
import os, sys
|
||||
from ConfigParser import SafeConfigParser
|
||||
|
||||
# This dequote() business is required for some older versions
|
||||
# of mysql_config
|
||||
|
||||
def dequote(s):
|
||||
if s[0] in "\"'" and s[0] == s[-1]:
|
||||
s = s[1:-1]
|
||||
return s
|
||||
|
||||
def compiler_flag(f):
|
||||
return "-%s" % f
|
||||
|
||||
def mysql_config(what):
|
||||
from os import popen
|
||||
|
||||
f = popen("%s --%s" % (mysql_config.path, what))
|
||||
data = f.read().strip().split()
|
||||
ret = f.close()
|
||||
if ret:
|
||||
if ret/256:
|
||||
data = []
|
||||
if ret/256 > 1:
|
||||
raise EnvironmentError("%s not found" % (mysql_config.path,))
|
||||
return data
|
||||
mysql_config.path = "mysql_config"
|
||||
|
||||
def get_config():
|
||||
from setup_common import get_metadata_and_options, enabled, create_release_file
|
||||
|
||||
metadata, options = get_metadata_and_options()
|
||||
|
||||
if 'mysql_config' in options:
|
||||
mysql_config.path = options['mysql_config']
|
||||
|
||||
extra_objects = []
|
||||
static = enabled(options, 'static')
|
||||
if enabled(options, 'embedded'):
|
||||
libs = mysql_config("libmysqld-libs")
|
||||
client = "mysqld"
|
||||
elif enabled(options, 'threadsafe'):
|
||||
libs = mysql_config("libs_r")
|
||||
client = "mysqlclient_r"
|
||||
if not libs:
|
||||
libs = mysql_config("libs")
|
||||
client = "mysqlclient"
|
||||
else:
|
||||
libs = mysql_config("libs")
|
||||
client = "mysqlclient"
|
||||
|
||||
library_dirs = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("L")) ]
|
||||
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
|
||||
|
||||
removable_compile_args = [ compiler_flag(f) for f in "ILl" ]
|
||||
extra_compile_args = [ i.replace("%", "%%") for i in mysql_config("cflags")
|
||||
if i[:2] not in removable_compile_args ]
|
||||
|
||||
# Copy the arch flags for linking as well
|
||||
extra_link_args = list()
|
||||
for i in range(len(extra_compile_args)):
|
||||
if extra_compile_args[i] == '-arch':
|
||||
extra_link_args += ['-arch', extra_compile_args[i + 1]]
|
||||
|
||||
include_dirs = [ dequote(i[2:])
|
||||
for i in mysql_config('include')
|
||||
if i.startswith(compiler_flag('I')) ]
|
||||
if not include_dirs: # fix for MySQL-3.23
|
||||
include_dirs = [ dequote(i[2:])
|
||||
for i in mysql_config('cflags')
|
||||
if i.startswith(compiler_flag('I')) ]
|
||||
|
||||
if static:
|
||||
extra_objects.append(os.path.join(
|
||||
library_dirs[0],'lib%s.a' % client))
|
||||
|
||||
name = "MySQL-python"
|
||||
if enabled(options, 'embedded'):
|
||||
name = name + "-embedded"
|
||||
metadata['name'] = name
|
||||
|
||||
define_macros = [
|
||||
('version_info', metadata['version_info']),
|
||||
('__version__', metadata['version']),
|
||||
]
|
||||
create_release_file(metadata)
|
||||
del metadata['version_info']
|
||||
ext_options = dict(
|
||||
name = "_mysql",
|
||||
library_dirs = library_dirs,
|
||||
libraries = libraries,
|
||||
extra_compile_args = extra_compile_args,
|
||||
extra_link_args = extra_link_args,
|
||||
include_dirs = include_dirs,
|
||||
extra_objects = extra_objects,
|
||||
define_macros = define_macros,
|
||||
)
|
||||
return metadata, ext_options
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.stderr.write("""You shouldn't be running this directly; it is used by setup.py.""")
|
||||
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
import os, sys
|
||||
|
||||
def get_config():
|
||||
from setup_common import get_metadata_and_options, enabled, create_release_file
|
||||
|
||||
metadata, options = get_metadata_and_options()
|
||||
|
||||
connector = options["connector"]
|
||||
|
||||
extra_objects = []
|
||||
|
||||
if enabled(options, 'embedded'):
|
||||
client = "mysqld"
|
||||
else:
|
||||
client = "mysqlclient"
|
||||
|
||||
library_dirs = [ os.path.join(connector, r'lib\opt') ]
|
||||
libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
|
||||
include_dirs = [ os.path.join(connector, r'include') ]
|
||||
extra_compile_args = [ '/Zl' ]
|
||||
|
||||
name = "MySQL-python"
|
||||
if enabled(options, 'embedded'):
|
||||
name = name + "-embedded"
|
||||
metadata['name'] = name
|
||||
|
||||
define_macros = [
|
||||
('version_info', metadata['version_info']),
|
||||
('__version__', metadata['version']),
|
||||
]
|
||||
create_release_file(metadata)
|
||||
del metadata['version_info']
|
||||
ext_options = dict(
|
||||
name = "_mysql",
|
||||
library_dirs = library_dirs,
|
||||
libraries = libraries,
|
||||
extra_compile_args = extra_compile_args,
|
||||
include_dirs = include_dirs,
|
||||
extra_objects = extra_objects,
|
||||
define_macros = define_macros,
|
||||
)
|
||||
return metadata, ext_options
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.stderr.write("""You shouldn't be running this directly; it is used by setup.py.""")
|
||||
|
||||
import os, sys
|
||||
|
||||
def get_config():
|
||||
from setup_common import get_metadata_and_options, enabled, create_release_file
|
||||
|
||||
metadata, options = get_metadata_and_options()
|
||||
|
||||
connector = options["connector"]
|
||||
|
||||
extra_objects = []
|
||||
|
||||
if enabled(options, 'embedded'):
|
||||
client = "mysqld"
|
||||
else:
|
||||
client = "mysqlclient"
|
||||
|
||||
library_dirs = [ os.path.join(connector, r'lib\opt') ]
|
||||
libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
|
||||
include_dirs = [ os.path.join(connector, r'include') ]
|
||||
extra_compile_args = [ '/Zl' ]
|
||||
|
||||
name = "MySQL-python"
|
||||
if enabled(options, 'embedded'):
|
||||
name = name + "-embedded"
|
||||
metadata['name'] = name
|
||||
|
||||
define_macros = [
|
||||
('version_info', metadata['version_info']),
|
||||
('__version__', metadata['version']),
|
||||
]
|
||||
create_release_file(metadata)
|
||||
del metadata['version_info']
|
||||
ext_options = dict(
|
||||
name = "_mysql",
|
||||
library_dirs = library_dirs,
|
||||
libraries = libraries,
|
||||
extra_compile_args = extra_compile_args,
|
||||
include_dirs = include_dirs,
|
||||
extra_objects = extra_objects,
|
||||
define_macros = define_macros,
|
||||
)
|
||||
return metadata, ext_options
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.stderr.write("""You shouldn't be running this directly; it is used by setup.py.""")
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
[options]
|
||||
# embedded: link against the embedded server library
|
||||
# threadsafe: use the threadsafe client
|
||||
# static: link against a static library (probably required for embedded)
|
||||
|
||||
embedded = False
|
||||
threadsafe = True
|
||||
static = False
|
||||
|
||||
# The path to mysql_config.
|
||||
# Only use this if mysql_config is not on your PATH, or you have some weird
|
||||
# setup that requires it.
|
||||
#mysql_config = /usr/local/bin/mysql_config
|
||||
|
||||
# http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip
|
||||
# Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.
|
||||
[options]
|
||||
# embedded: link against the embedded server library
|
||||
# threadsafe: use the threadsafe client
|
||||
# static: link against a static library (probably required for embedded)
|
||||
|
||||
embedded = False
|
||||
threadsafe = True
|
||||
static = False
|
||||
|
||||
# The path to mysql_config.
|
||||
# Only use this if mysql_config is not on your PATH, or you have some weird
|
||||
# setup that requires it.
|
||||
#mysql_config = /usr/local/bin/mysql_config
|
||||
|
||||
# http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip
|
||||
# Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.
|
||||
connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2
|
||||
@@ -1,280 +1,280 @@
|
||||
#!/usr/bin/env python -O
|
||||
""" Script to test database capabilities and the DB-API interface
|
||||
for functionality and memory leaks.
|
||||
|
||||
Adapted from a script by M-A Lemburg.
|
||||
|
||||
"""
|
||||
from time import time
|
||||
import array
|
||||
import unittest
|
||||
|
||||
|
||||
class DatabaseTest(unittest.TestCase):
|
||||
|
||||
db_module = None
|
||||
connect_args = ()
|
||||
connect_kwargs = dict()
|
||||
create_table_extra = ''
|
||||
rows = 10
|
||||
debug = False
|
||||
|
||||
def setUp(self):
|
||||
import gc
|
||||
db = self.db_module.connect(*self.connect_args, **self.connect_kwargs)
|
||||
self.connection = db
|
||||
self.cursor = db.cursor()
|
||||
# TODO: this needs to be re-evaluated for Python 3
|
||||
self.BLOBText = ''.join([chr(i) for i in range(256)] * 100);
|
||||
self.BLOBUText = u''.join([unichr(i) for i in range(16384)])
|
||||
self.BLOBBinary = self.db_module.Binary(''.join([chr(i) for i in range(256)] * 16))
|
||||
|
||||
leak_test = True
|
||||
|
||||
def tearDown(self):
|
||||
if self.leak_test:
|
||||
import gc
|
||||
del self.cursor
|
||||
orphans = gc.collect()
|
||||
self.failIf(orphans, "%d orphaned objects found after deleting cursor" % orphans)
|
||||
|
||||
del self.connection
|
||||
orphans = gc.collect()
|
||||
self.failIf(orphans, "%d orphaned objects found after deleting connection" % orphans)
|
||||
|
||||
def table_exists(self, name):
|
||||
try:
|
||||
self.cursor.execute('select * from %s where 1=0' % name)
|
||||
except:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def quote_identifier(self, ident):
|
||||
return '"%s"' % ident
|
||||
|
||||
def new_table_name(self):
|
||||
i = id(self.cursor)
|
||||
while True:
|
||||
name = self.quote_identifier('tb%08x' % i)
|
||||
if not self.table_exists(name):
|
||||
return name
|
||||
i = i + 1
|
||||
|
||||
def create_table(self, columndefs):
|
||||
|
||||
""" Create a table using a list of column definitions given in
|
||||
columndefs.
|
||||
|
||||
generator must be a function taking arguments (row_number,
|
||||
col_number) returning a suitable data object for insertion
|
||||
into the table.
|
||||
|
||||
"""
|
||||
self.table = self.new_table_name()
|
||||
self.cursor.execute('CREATE TABLE %s (%s) %s' %
|
||||
(self.table,
|
||||
',\n'.join(columndefs),
|
||||
self.create_table_extra))
|
||||
|
||||
def check_data_integrity(self, columndefs, generator):
|
||||
# insert
|
||||
self.create_table(columndefs)
|
||||
insert_statement = ('INSERT INTO %s VALUES (%s)' %
|
||||
(self.table,
|
||||
','.join(['%s'] * len(columndefs))))
|
||||
data = [ [ generator(i,j) for j in range(len(columndefs)) ]
|
||||
for i in range(self.rows) ]
|
||||
self.cursor.executemany(insert_statement, data)
|
||||
self.connection.commit()
|
||||
# verify
|
||||
self.cursor.execute('select * from %s' % self.table)
|
||||
l = self.cursor.fetchall()
|
||||
self.assertEquals(len(l), self.rows)
|
||||
try:
|
||||
for i in range(self.rows):
|
||||
for j in range(len(columndefs)):
|
||||
self.assertEquals(l[i][j], generator(i,j))
|
||||
finally:
|
||||
if not self.debug:
|
||||
self.cursor.execute('drop table %s' % (self.table))
|
||||
|
||||
def test_transactions(self):
|
||||
columndefs = ( 'col1 INT', 'col2 VARCHAR(255)')
|
||||
def generator(row, col):
|
||||
if col == 0: return row
|
||||
else: return ('%i' % (row%10))*255
|
||||
self.create_table(columndefs)
|
||||
insert_statement = ('INSERT INTO %s VALUES (%s)' %
|
||||
(self.table,
|
||||
','.join(['%s'] * len(columndefs))))
|
||||
data = [ [ generator(i,j) for j in range(len(columndefs)) ]
|
||||
for i in range(self.rows) ]
|
||||
self.cursor.executemany(insert_statement, data)
|
||||
# verify
|
||||
self.connection.commit()
|
||||
self.cursor.execute('select * from %s' % self.table)
|
||||
l = self.cursor.fetchall()
|
||||
self.assertEquals(len(l), self.rows)
|
||||
for i in range(self.rows):
|
||||
for j in range(len(columndefs)):
|
||||
self.assertEquals(l[i][j], generator(i,j))
|
||||
delete_statement = 'delete from %s where col1=%%s' % self.table
|
||||
self.cursor.execute(delete_statement, (0,))
|
||||
self.cursor.execute('select col1 from %s where col1=%s' % \
|
||||
(self.table, 0))
|
||||
l = self.cursor.fetchall()
|
||||
self.assertFalse(l, "DELETE didn't work")
|
||||
self.connection.rollback()
|
||||
self.cursor.execute('select col1 from %s where col1=%s' % \
|
||||
(self.table, 0))
|
||||
l = self.cursor.fetchall()
|
||||
self.assertTrue(len(l) == 1, "ROLLBACK didn't work")
|
||||
self.cursor.execute('drop table %s' % (self.table))
|
||||
|
||||
def test_truncation(self):
|
||||
columndefs = ( 'col1 INT', 'col2 VARCHAR(255)')
|
||||
def generator(row, col):
|
||||
if col == 0: return row
|
||||
else: return ('%i' % (row%10))*((255-self.rows/2)+row)
|
||||
self.create_table(columndefs)
|
||||
insert_statement = ('INSERT INTO %s VALUES (%s)' %
|
||||
(self.table,
|
||||
','.join(['%s'] * len(columndefs))))
|
||||
|
||||
try:
|
||||
self.cursor.execute(insert_statement, (0, '0'*256))
|
||||
except self.connection.DataError:
|
||||
pass
|
||||
else:
|
||||
self.fail("Over-long column did not generate warnings/exception with single insert")
|
||||
|
||||
self.connection.rollback()
|
||||
|
||||
try:
|
||||
for i in range(self.rows):
|
||||
data = []
|
||||
for j in range(len(columndefs)):
|
||||
data.append(generator(i,j))
|
||||
self.cursor.execute(insert_statement,tuple(data))
|
||||
except self.connection.DataError:
|
||||
pass
|
||||
else:
|
||||
self.fail("Over-long columns did not generate warnings/exception with execute()")
|
||||
|
||||
self.connection.rollback()
|
||||
|
||||
try:
|
||||
data = [ [ generator(i,j) for j in range(len(columndefs)) ]
|
||||
for i in range(self.rows) ]
|
||||
self.cursor.executemany(insert_statement, data)
|
||||
except self.connection.DataError:
|
||||
pass
|
||||
else:
|
||||
self.fail("Over-long columns did not generate warnings/exception with executemany()")
|
||||
|
||||
self.connection.rollback()
|
||||
self.cursor.execute('drop table %s' % (self.table))
|
||||
|
||||
def test_CHAR(self):
|
||||
# Character data
|
||||
def generator(row,col):
|
||||
return ('%i' % ((row+col) % 10)) * 255
|
||||
self.check_data_integrity(
|
||||
('col1 char(255)','col2 char(255)'),
|
||||
generator)
|
||||
|
||||
def test_INT(self):
|
||||
# Number data
|
||||
def generator(row,col):
|
||||
return row*row
|
||||
self.check_data_integrity(
|
||||
('col1 INT',),
|
||||
generator)
|
||||
|
||||
def test_DECIMAL(self):
|
||||
# DECIMAL
|
||||
def generator(row,col):
|
||||
from decimal import Decimal
|
||||
return Decimal("%d.%02d" % (row, col))
|
||||
self.check_data_integrity(
|
||||
('col1 DECIMAL(5,2)',),
|
||||
generator)
|
||||
|
||||
def test_DATE(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.DateFromTicks(ticks+row*86400-col*1313)
|
||||
self.check_data_integrity(
|
||||
('col1 DATE',),
|
||||
generator)
|
||||
|
||||
def test_TIME(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.TimeFromTicks(ticks+row*86400-col*1313)
|
||||
self.check_data_integrity(
|
||||
('col1 TIME',),
|
||||
generator)
|
||||
|
||||
def test_DATETIME(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.TimestampFromTicks(ticks+row*86400-col*1313)
|
||||
self.check_data_integrity(
|
||||
('col1 DATETIME',),
|
||||
generator)
|
||||
|
||||
def test_TIMESTAMP(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.TimestampFromTicks(ticks+row*86400-col*1313)
|
||||
self.check_data_integrity(
|
||||
('col1 TIMESTAMP',),
|
||||
generator)
|
||||
|
||||
def test_fractional_TIMESTAMP(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.TimestampFromTicks(ticks+row*86400-col*1313+row*0.7*col/3.0)
|
||||
self.check_data_integrity(
|
||||
('col1 TIMESTAMP',),
|
||||
generator)
|
||||
|
||||
def test_LONG(self):
|
||||
def generator(row,col):
|
||||
if col == 0:
|
||||
return row
|
||||
else:
|
||||
return self.BLOBUText # 'BLOB Text ' * 1024
|
||||
self.check_data_integrity(
|
||||
('col1 INT','col2 LONG'),
|
||||
generator)
|
||||
|
||||
def test_TEXT(self):
|
||||
def generator(row,col):
|
||||
return self.BLOBUText # 'BLOB Text ' * 1024
|
||||
self.check_data_integrity(
|
||||
('col2 TEXT',),
|
||||
generator)
|
||||
|
||||
def test_LONG_BYTE(self):
|
||||
def generator(row,col):
|
||||
if col == 0:
|
||||
return row
|
||||
else:
|
||||
return self.BLOBBinary # 'BLOB\000Binary ' * 1024
|
||||
self.check_data_integrity(
|
||||
('col1 INT','col2 LONG BYTE'),
|
||||
generator)
|
||||
|
||||
def test_BLOB(self):
|
||||
def generator(row,col):
|
||||
if col == 0:
|
||||
return row
|
||||
else:
|
||||
return self.BLOBBinary # 'BLOB\000Binary ' * 1024
|
||||
self.check_data_integrity(
|
||||
('col1 INT','col2 BLOB'),
|
||||
generator)
|
||||
|
||||
#!/usr/bin/env python -O
|
||||
""" Script to test database capabilities and the DB-API interface
|
||||
for functionality and memory leaks.
|
||||
|
||||
Adapted from a script by M-A Lemburg.
|
||||
|
||||
"""
|
||||
from time import time
|
||||
import array
|
||||
import unittest
|
||||
|
||||
|
||||
class DatabaseTest(unittest.TestCase):
|
||||
|
||||
db_module = None
|
||||
connect_args = ()
|
||||
connect_kwargs = dict()
|
||||
create_table_extra = ''
|
||||
rows = 10
|
||||
debug = False
|
||||
|
||||
def setUp(self):
|
||||
import gc
|
||||
db = self.db_module.connect(*self.connect_args, **self.connect_kwargs)
|
||||
self.connection = db
|
||||
self.cursor = db.cursor()
|
||||
# TODO: this needs to be re-evaluated for Python 3
|
||||
self.BLOBText = ''.join([chr(i) for i in range(256)] * 100);
|
||||
self.BLOBUText = u''.join([unichr(i) for i in range(16384)])
|
||||
self.BLOBBinary = self.db_module.Binary(''.join([chr(i) for i in range(256)] * 16))
|
||||
|
||||
leak_test = True
|
||||
|
||||
def tearDown(self):
|
||||
if self.leak_test:
|
||||
import gc
|
||||
del self.cursor
|
||||
orphans = gc.collect()
|
||||
self.failIf(orphans, "%d orphaned objects found after deleting cursor" % orphans)
|
||||
|
||||
del self.connection
|
||||
orphans = gc.collect()
|
||||
self.failIf(orphans, "%d orphaned objects found after deleting connection" % orphans)
|
||||
|
||||
def table_exists(self, name):
|
||||
try:
|
||||
self.cursor.execute('select * from %s where 1=0' % name)
|
||||
except:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def quote_identifier(self, ident):
|
||||
return '"%s"' % ident
|
||||
|
||||
def new_table_name(self):
|
||||
i = id(self.cursor)
|
||||
while True:
|
||||
name = self.quote_identifier('tb%08x' % i)
|
||||
if not self.table_exists(name):
|
||||
return name
|
||||
i = i + 1
|
||||
|
||||
def create_table(self, columndefs):
|
||||
|
||||
""" Create a table using a list of column definitions given in
|
||||
columndefs.
|
||||
|
||||
generator must be a function taking arguments (row_number,
|
||||
col_number) returning a suitable data object for insertion
|
||||
into the table.
|
||||
|
||||
"""
|
||||
self.table = self.new_table_name()
|
||||
self.cursor.execute('CREATE TABLE %s (%s) %s' %
|
||||
(self.table,
|
||||
',\n'.join(columndefs),
|
||||
self.create_table_extra))
|
||||
|
||||
def check_data_integrity(self, columndefs, generator):
|
||||
# insert
|
||||
self.create_table(columndefs)
|
||||
insert_statement = ('INSERT INTO %s VALUES (%s)' %
|
||||
(self.table,
|
||||
','.join(['%s'] * len(columndefs))))
|
||||
data = [ [ generator(i,j) for j in range(len(columndefs)) ]
|
||||
for i in range(self.rows) ]
|
||||
self.cursor.executemany(insert_statement, data)
|
||||
self.connection.commit()
|
||||
# verify
|
||||
self.cursor.execute('select * from %s' % self.table)
|
||||
l = self.cursor.fetchall()
|
||||
self.assertEquals(len(l), self.rows)
|
||||
try:
|
||||
for i in range(self.rows):
|
||||
for j in range(len(columndefs)):
|
||||
self.assertEquals(l[i][j], generator(i,j))
|
||||
finally:
|
||||
if not self.debug:
|
||||
self.cursor.execute('drop table %s' % (self.table))
|
||||
|
||||
def test_transactions(self):
|
||||
columndefs = ( 'col1 INT', 'col2 VARCHAR(255)')
|
||||
def generator(row, col):
|
||||
if col == 0: return row
|
||||
else: return ('%i' % (row%10))*255
|
||||
self.create_table(columndefs)
|
||||
insert_statement = ('INSERT INTO %s VALUES (%s)' %
|
||||
(self.table,
|
||||
','.join(['%s'] * len(columndefs))))
|
||||
data = [ [ generator(i,j) for j in range(len(columndefs)) ]
|
||||
for i in range(self.rows) ]
|
||||
self.cursor.executemany(insert_statement, data)
|
||||
# verify
|
||||
self.connection.commit()
|
||||
self.cursor.execute('select * from %s' % self.table)
|
||||
l = self.cursor.fetchall()
|
||||
self.assertEquals(len(l), self.rows)
|
||||
for i in range(self.rows):
|
||||
for j in range(len(columndefs)):
|
||||
self.assertEquals(l[i][j], generator(i,j))
|
||||
delete_statement = 'delete from %s where col1=%%s' % self.table
|
||||
self.cursor.execute(delete_statement, (0,))
|
||||
self.cursor.execute('select col1 from %s where col1=%s' % \
|
||||
(self.table, 0))
|
||||
l = self.cursor.fetchall()
|
||||
self.assertFalse(l, "DELETE didn't work")
|
||||
self.connection.rollback()
|
||||
self.cursor.execute('select col1 from %s where col1=%s' % \
|
||||
(self.table, 0))
|
||||
l = self.cursor.fetchall()
|
||||
self.assertTrue(len(l) == 1, "ROLLBACK didn't work")
|
||||
self.cursor.execute('drop table %s' % (self.table))
|
||||
|
||||
def test_truncation(self):
|
||||
columndefs = ( 'col1 INT', 'col2 VARCHAR(255)')
|
||||
def generator(row, col):
|
||||
if col == 0: return row
|
||||
else: return ('%i' % (row%10))*((255-self.rows/2)+row)
|
||||
self.create_table(columndefs)
|
||||
insert_statement = ('INSERT INTO %s VALUES (%s)' %
|
||||
(self.table,
|
||||
','.join(['%s'] * len(columndefs))))
|
||||
|
||||
try:
|
||||
self.cursor.execute(insert_statement, (0, '0'*256))
|
||||
except self.connection.DataError:
|
||||
pass
|
||||
else:
|
||||
self.fail("Over-long column did not generate warnings/exception with single insert")
|
||||
|
||||
self.connection.rollback()
|
||||
|
||||
try:
|
||||
for i in range(self.rows):
|
||||
data = []
|
||||
for j in range(len(columndefs)):
|
||||
data.append(generator(i,j))
|
||||
self.cursor.execute(insert_statement,tuple(data))
|
||||
except self.connection.DataError:
|
||||
pass
|
||||
else:
|
||||
self.fail("Over-long columns did not generate warnings/exception with execute()")
|
||||
|
||||
self.connection.rollback()
|
||||
|
||||
try:
|
||||
data = [ [ generator(i,j) for j in range(len(columndefs)) ]
|
||||
for i in range(self.rows) ]
|
||||
self.cursor.executemany(insert_statement, data)
|
||||
except self.connection.DataError:
|
||||
pass
|
||||
else:
|
||||
self.fail("Over-long columns did not generate warnings/exception with executemany()")
|
||||
|
||||
self.connection.rollback()
|
||||
self.cursor.execute('drop table %s' % (self.table))
|
||||
|
||||
def test_CHAR(self):
|
||||
# Character data
|
||||
def generator(row,col):
|
||||
return ('%i' % ((row+col) % 10)) * 255
|
||||
self.check_data_integrity(
|
||||
('col1 char(255)','col2 char(255)'),
|
||||
generator)
|
||||
|
||||
def test_INT(self):
|
||||
# Number data
|
||||
def generator(row,col):
|
||||
return row*row
|
||||
self.check_data_integrity(
|
||||
('col1 INT',),
|
||||
generator)
|
||||
|
||||
def test_DECIMAL(self):
|
||||
# DECIMAL
|
||||
def generator(row,col):
|
||||
from decimal import Decimal
|
||||
return Decimal("%d.%02d" % (row, col))
|
||||
self.check_data_integrity(
|
||||
('col1 DECIMAL(5,2)',),
|
||||
generator)
|
||||
|
||||
def test_DATE(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.DateFromTicks(ticks+row*86400-col*1313)
|
||||
self.check_data_integrity(
|
||||
('col1 DATE',),
|
||||
generator)
|
||||
|
||||
def test_TIME(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.TimeFromTicks(ticks+row*86400-col*1313)
|
||||
self.check_data_integrity(
|
||||
('col1 TIME',),
|
||||
generator)
|
||||
|
||||
def test_DATETIME(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.TimestampFromTicks(ticks+row*86400-col*1313)
|
||||
self.check_data_integrity(
|
||||
('col1 DATETIME',),
|
||||
generator)
|
||||
|
||||
def test_TIMESTAMP(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.TimestampFromTicks(ticks+row*86400-col*1313)
|
||||
self.check_data_integrity(
|
||||
('col1 TIMESTAMP',),
|
||||
generator)
|
||||
|
||||
def test_fractional_TIMESTAMP(self):
|
||||
ticks = time()
|
||||
def generator(row,col):
|
||||
return self.db_module.TimestampFromTicks(ticks+row*86400-col*1313+row*0.7*col/3.0)
|
||||
self.check_data_integrity(
|
||||
('col1 TIMESTAMP',),
|
||||
generator)
|
||||
|
||||
def test_LONG(self):
|
||||
def generator(row,col):
|
||||
if col == 0:
|
||||
return row
|
||||
else:
|
||||
return self.BLOBUText # 'BLOB Text ' * 1024
|
||||
self.check_data_integrity(
|
||||
('col1 INT','col2 LONG'),
|
||||
generator)
|
||||
|
||||
def test_TEXT(self):
|
||||
def generator(row,col):
|
||||
return self.BLOBUText # 'BLOB Text ' * 1024
|
||||
self.check_data_integrity(
|
||||
('col2 TEXT',),
|
||||
generator)
|
||||
|
||||
def test_LONG_BYTE(self):
|
||||
def generator(row,col):
|
||||
if col == 0:
|
||||
return row
|
||||
else:
|
||||
return self.BLOBBinary # 'BLOB\000Binary ' * 1024
|
||||
self.check_data_integrity(
|
||||
('col1 INT','col2 LONG BYTE'),
|
||||
generator)
|
||||
|
||||
def test_BLOB(self):
|
||||
def generator(row,col):
|
||||
if col == 0:
|
||||
return row
|
||||
else:
|
||||
return self.BLOBBinary # 'BLOB\000Binary ' * 1024
|
||||
self.check_data_integrity(
|
||||
('col1 INT','col2 BLOB'),
|
||||
generator)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,103 +1,103 @@
|
||||
#!/usr/bin/env python
|
||||
import capabilities
|
||||
import unittest
|
||||
import MySQLdb
|
||||
import warnings
|
||||
|
||||
warnings.filterwarnings('error')
|
||||
|
||||
class test_MySQLdb(capabilities.DatabaseTest):
|
||||
|
||||
db_module = MySQLdb
|
||||
connect_args = ()
|
||||
connect_kwargs = dict(db='test', host="127.0.0.1", user="test", #read_default_file='~/.my.cnf',
|
||||
charset='utf8', sql_mode="ANSI,STRICT_TRANS_TABLES,TRADITIONAL")
|
||||
create_table_extra = "ENGINE=INNODB CHARACTER SET UTF8"
|
||||
leak_test = False
|
||||
|
||||
def quote_identifier(self, ident):
|
||||
return "`%s`" % ident
|
||||
|
||||
def test_TIME(self):
|
||||
from datetime import timedelta
|
||||
def generator(row,col):
|
||||
return timedelta(0, row*8000)
|
||||
self.check_data_integrity(
|
||||
('col1 TIME',),
|
||||
generator)
|
||||
|
||||
def test_TINYINT(self):
|
||||
# Number data
|
||||
def generator(row,col):
|
||||
v = (row*row) % 256
|
||||
if v > 127:
|
||||
v = v-256
|
||||
return v
|
||||
self.check_data_integrity(
|
||||
('col1 TINYINT',),
|
||||
generator)
|
||||
|
||||
def test_stored_procedures(self):
|
||||
db = self.connection
|
||||
c = self.cursor
|
||||
self.create_table(('pos INT', 'tree CHAR(20)'))
|
||||
c.executemany("INSERT INTO %s (pos,tree) VALUES (%%s,%%s)" % self.table,
|
||||
list(enumerate('ash birch cedar larch pine'.split())))
|
||||
db.commit()
|
||||
|
||||
c.execute("""
|
||||
CREATE PROCEDURE test_sp(IN t VARCHAR(255))
|
||||
BEGIN
|
||||
SELECT pos FROM %s WHERE tree = t;
|
||||
END
|
||||
""" % self.table)
|
||||
db.commit()
|
||||
|
||||
c.callproc('test_sp', ('larch',))
|
||||
rows = c.fetchall()
|
||||
self.assertEquals(len(rows), 1)
|
||||
self.assertEquals(rows[0][0], 3)
|
||||
c.nextset()
|
||||
|
||||
c.execute("DROP PROCEDURE test_sp")
|
||||
c.execute('drop table %s' % (self.table))
|
||||
|
||||
def test_small_CHAR(self):
|
||||
# Character data
|
||||
def generator(row,col):
|
||||
i = (row*col+62)%256
|
||||
if i == 62: return ''
|
||||
if i == 63: return None
|
||||
return chr(i)
|
||||
self.check_data_integrity(
|
||||
('col1 char(1)','col2 char(1)'),
|
||||
generator)
|
||||
|
||||
def test_bug_2671682(self):
|
||||
from MySQLdb.constants import ER
|
||||
try:
|
||||
self.cursor.execute("describe some_non_existent_table");
|
||||
except self.connection.ProgrammingError as msg:
|
||||
self.assertTrue(msg.args[0].args[0] == ER.NO_SUCH_TABLE)
|
||||
|
||||
def test_bug_3514287(self):
|
||||
c = self.cursor
|
||||
try:
|
||||
c.execute("""create table bug_3541287 (
|
||||
c1 CHAR(10),
|
||||
t1 TIMESTAMP)""")
|
||||
c.execute("insert into bug_3541287 (c1,t1) values (%s, NOW())",
|
||||
("blah",))
|
||||
finally:
|
||||
c.execute("drop table if exists bug_3541287")
|
||||
|
||||
def test_ping(self):
|
||||
self.connection.ping()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if test_MySQLdb.leak_test:
|
||||
import gc
|
||||
gc.enable()
|
||||
gc.set_debug(gc.DEBUG_LEAK)
|
||||
unittest.main()
|
||||
#!/usr/bin/env python
|
||||
import capabilities
|
||||
import unittest
|
||||
import MySQLdb
|
||||
import warnings
|
||||
|
||||
warnings.filterwarnings('error')
|
||||
|
||||
class test_MySQLdb(capabilities.DatabaseTest):
|
||||
|
||||
db_module = MySQLdb
|
||||
connect_args = ()
|
||||
connect_kwargs = dict(db='test', host="127.0.0.1", user="test", #read_default_file='~/.my.cnf',
|
||||
charset='utf8', sql_mode="ANSI,STRICT_TRANS_TABLES,TRADITIONAL")
|
||||
create_table_extra = "ENGINE=INNODB CHARACTER SET UTF8"
|
||||
leak_test = False
|
||||
|
||||
def quote_identifier(self, ident):
|
||||
return "`%s`" % ident
|
||||
|
||||
def test_TIME(self):
|
||||
from datetime import timedelta
|
||||
def generator(row,col):
|
||||
return timedelta(0, row*8000)
|
||||
self.check_data_integrity(
|
||||
('col1 TIME',),
|
||||
generator)
|
||||
|
||||
def test_TINYINT(self):
|
||||
# Number data
|
||||
def generator(row,col):
|
||||
v = (row*row) % 256
|
||||
if v > 127:
|
||||
v = v-256
|
||||
return v
|
||||
self.check_data_integrity(
|
||||
('col1 TINYINT',),
|
||||
generator)
|
||||
|
||||
def test_stored_procedures(self):
|
||||
db = self.connection
|
||||
c = self.cursor
|
||||
self.create_table(('pos INT', 'tree CHAR(20)'))
|
||||
c.executemany("INSERT INTO %s (pos,tree) VALUES (%%s,%%s)" % self.table,
|
||||
list(enumerate('ash birch cedar larch pine'.split())))
|
||||
db.commit()
|
||||
|
||||
c.execute("""
|
||||
CREATE PROCEDURE test_sp(IN t VARCHAR(255))
|
||||
BEGIN
|
||||
SELECT pos FROM %s WHERE tree = t;
|
||||
END
|
||||
""" % self.table)
|
||||
db.commit()
|
||||
|
||||
c.callproc('test_sp', ('larch',))
|
||||
rows = c.fetchall()
|
||||
self.assertEquals(len(rows), 1)
|
||||
self.assertEquals(rows[0][0], 3)
|
||||
c.nextset()
|
||||
|
||||
c.execute("DROP PROCEDURE test_sp")
|
||||
c.execute('drop table %s' % (self.table))
|
||||
|
||||
def test_small_CHAR(self):
|
||||
# Character data
|
||||
def generator(row,col):
|
||||
i = (row*col+62)%256
|
||||
if i == 62: return ''
|
||||
if i == 63: return None
|
||||
return chr(i)
|
||||
self.check_data_integrity(
|
||||
('col1 char(1)','col2 char(1)'),
|
||||
generator)
|
||||
|
||||
def test_bug_2671682(self):
|
||||
from MySQLdb.constants import ER
|
||||
try:
|
||||
self.cursor.execute("describe some_non_existent_table");
|
||||
except self.connection.ProgrammingError as msg:
|
||||
self.assertTrue(msg.args[0].args[0] == ER.NO_SUCH_TABLE)
|
||||
|
||||
def test_bug_3514287(self):
|
||||
c = self.cursor
|
||||
try:
|
||||
c.execute("""create table bug_3541287 (
|
||||
c1 CHAR(10),
|
||||
t1 TIMESTAMP)""")
|
||||
c.execute("insert into bug_3541287 (c1,t1) values (%s, NOW())",
|
||||
("blah",))
|
||||
finally:
|
||||
c.execute("drop table if exists bug_3541287")
|
||||
|
||||
def test_ping(self):
|
||||
self.connection.ping()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if test_MySQLdb.leak_test:
|
||||
import gc
|
||||
gc.enable()
|
||||
gc.set_debug(gc.DEBUG_LEAK)
|
||||
unittest.main()
|
||||
|
||||
@@ -1,205 +1,205 @@
|
||||
#!/usr/bin/env python
|
||||
import dbapi20
|
||||
import unittest
|
||||
import MySQLdb
|
||||
|
||||
class test_MySQLdb(dbapi20.DatabaseAPI20Test):
|
||||
driver = MySQLdb
|
||||
connect_args = ()
|
||||
connect_kw_args = dict(db='test',
|
||||
host="127.0.0.1",
|
||||
user="test", #read_default_file='~/.my.cnf',
|
||||
charset='utf8',
|
||||
sql_mode="ANSI,STRICT_TRANS_TABLES,TRADITIONAL")
|
||||
|
||||
def test_setoutputsize(self): pass
|
||||
def test_setoutputsize_basic(self): pass
|
||||
def test_nextset(self): pass
|
||||
|
||||
"""The tests on fetchone and fetchall and rowcount bogusly
|
||||
test for an exception if the statement cannot return a
|
||||
result set. MySQL always returns a result set; it's just that
|
||||
some things return empty result sets."""
|
||||
|
||||
def test_fetchall(self):
|
||||
con = self._connect()
|
||||
try:
|
||||
cur = con.cursor()
|
||||
# cursor.fetchall should raise an Error if called
|
||||
# without executing a query that may return rows (such
|
||||
# as a select)
|
||||
self.assertRaises(self.driver.Error, cur.fetchall)
|
||||
|
||||
self.executeDDL1(cur)
|
||||
for sql in self._populate():
|
||||
cur.execute(sql)
|
||||
|
||||
# cursor.fetchall should raise an Error if called
|
||||
# after executing a a statement that cannot return rows
|
||||
## self.assertRaises(self.driver.Error,cur.fetchall)
|
||||
|
||||
cur.execute('select name from %sbooze' % self.table_prefix)
|
||||
rows = cur.fetchall()
|
||||
self.assertTrue(cur.rowcount in (-1,len(self.samples)))
|
||||
self.assertEqual(len(rows),len(self.samples),
|
||||
'cursor.fetchall did not retrieve all rows'
|
||||
)
|
||||
rows = [r[0] for r in rows]
|
||||
rows.sort()
|
||||
for i in range(0,len(self.samples)):
|
||||
self.assertEqual(rows[i],self.samples[i],
|
||||
'cursor.fetchall retrieved incorrect rows'
|
||||
)
|
||||
rows = cur.fetchall()
|
||||
self.assertEqual(
|
||||
len(rows),0,
|
||||
'cursor.fetchall should return an empty list if called '
|
||||
'after the whole result set has been fetched'
|
||||
)
|
||||
self.assertTrue(cur.rowcount in (-1,len(self.samples)))
|
||||
|
||||
self.executeDDL2(cur)
|
||||
cur.execute('select name from %sbarflys' % self.table_prefix)
|
||||
rows = cur.fetchall()
|
||||
self.assertTrue(cur.rowcount in (-1,0))
|
||||
self.assertEqual(len(rows),0,
|
||||
'cursor.fetchall should return an empty list if '
|
||||
'a select query returns no rows'
|
||||
)
|
||||
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
def test_fetchone(self):
|
||||
con = self._connect()
|
||||
try:
|
||||
cur = con.cursor()
|
||||
|
||||
# cursor.fetchone should raise an Error if called before
|
||||
# executing a select-type query
|
||||
self.assertRaises(self.driver.Error,cur.fetchone)
|
||||
|
||||
# cursor.fetchone should raise an Error if called after
|
||||
# executing a query that cannnot return rows
|
||||
self.executeDDL1(cur)
|
||||
## self.assertRaises(self.driver.Error,cur.fetchone)
|
||||
|
||||
cur.execute('select name from %sbooze' % self.table_prefix)
|
||||
self.assertEqual(cur.fetchone(),None,
|
||||
'cursor.fetchone should return None if a query retrieves '
|
||||
'no rows'
|
||||
)
|
||||
self.assertTrue(cur.rowcount in (-1,0))
|
||||
|
||||
# cursor.fetchone should raise an Error if called after
|
||||
# executing a query that cannnot return rows
|
||||
cur.execute("insert into %sbooze values ('Victoria Bitter')" % (
|
||||
self.table_prefix
|
||||
))
|
||||
## self.assertRaises(self.driver.Error,cur.fetchone)
|
||||
|
||||
cur.execute('select name from %sbooze' % self.table_prefix)
|
||||
r = cur.fetchone()
|
||||
self.assertEqual(len(r),1,
|
||||
'cursor.fetchone should have retrieved a single row'
|
||||
)
|
||||
self.assertEqual(r[0],'Victoria Bitter',
|
||||
'cursor.fetchone retrieved incorrect data'
|
||||
)
|
||||
## self.assertEqual(cur.fetchone(),None,
|
||||
## 'cursor.fetchone should return None if no more rows available'
|
||||
## )
|
||||
self.assertTrue(cur.rowcount in (-1,1))
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
# Same complaint as for fetchall and fetchone
|
||||
def test_rowcount(self):
|
||||
con = self._connect()
|
||||
try:
|
||||
cur = con.cursor()
|
||||
self.executeDDL1(cur)
|
||||
## self.assertEqual(cur.rowcount,-1,
|
||||
## 'cursor.rowcount should be -1 after executing no-result '
|
||||
## 'statements'
|
||||
## )
|
||||
cur.execute("insert into %sbooze values ('Victoria Bitter')" % (
|
||||
self.table_prefix
|
||||
))
|
||||
## self.assertTrue(cur.rowcount in (-1,1),
|
||||
## 'cursor.rowcount should == number or rows inserted, or '
|
||||
## 'set to -1 after executing an insert statement'
|
||||
## )
|
||||
cur.execute("select name from %sbooze" % self.table_prefix)
|
||||
self.assertTrue(cur.rowcount in (-1,1),
|
||||
'cursor.rowcount should == number of rows returned, or '
|
||||
'set to -1 after executing a select statement'
|
||||
)
|
||||
self.executeDDL2(cur)
|
||||
## self.assertEqual(cur.rowcount,-1,
|
||||
## 'cursor.rowcount not being reset to -1 after executing '
|
||||
## 'no-result statements'
|
||||
## )
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
def test_callproc(self):
|
||||
pass # performed in test_MySQL_capabilities
|
||||
|
||||
def help_nextset_setUp(self,cur):
|
||||
''' Should create a procedure called deleteme
|
||||
that returns two result sets, first the
|
||||
number of rows in booze then "name from booze"
|
||||
'''
|
||||
sql="""
|
||||
create procedure deleteme()
|
||||
begin
|
||||
select count(*) from %(tp)sbooze;
|
||||
select name from %(tp)sbooze;
|
||||
end
|
||||
""" % dict(tp=self.table_prefix)
|
||||
cur.execute(sql)
|
||||
|
||||
def help_nextset_tearDown(self,cur):
|
||||
'If cleaning up is needed after nextSetTest'
|
||||
cur.execute("drop procedure deleteme")
|
||||
|
||||
def test_nextset(self):
|
||||
from warnings import warn
|
||||
con = self._connect()
|
||||
try:
|
||||
cur = con.cursor()
|
||||
if not hasattr(cur,'nextset'):
|
||||
return
|
||||
|
||||
try:
|
||||
self.executeDDL1(cur)
|
||||
sql=self._populate()
|
||||
for sql in self._populate():
|
||||
cur.execute(sql)
|
||||
|
||||
self.help_nextset_setUp(cur)
|
||||
|
||||
cur.callproc('deleteme')
|
||||
numberofrows=cur.fetchone()
|
||||
assert numberofrows[0]== len(self.samples)
|
||||
assert cur.nextset()
|
||||
names=cur.fetchall()
|
||||
assert len(names) == len(self.samples)
|
||||
s=cur.nextset()
|
||||
if s:
|
||||
empty = cur.fetchall()
|
||||
self.assertEquals(len(empty), 0,
|
||||
"non-empty result set after other result sets")
|
||||
#warn("Incompatibility: MySQL returns an empty result set for the CALL itself",
|
||||
# Warning)
|
||||
#assert s == None,'No more return sets, should return None'
|
||||
finally:
|
||||
self.help_nextset_tearDown(cur)
|
||||
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
#!/usr/bin/env python
|
||||
import dbapi20
|
||||
import unittest
|
||||
import MySQLdb
|
||||
|
||||
class test_MySQLdb(dbapi20.DatabaseAPI20Test):
|
||||
driver = MySQLdb
|
||||
connect_args = ()
|
||||
connect_kw_args = dict(db='test',
|
||||
host="127.0.0.1",
|
||||
user="test", #read_default_file='~/.my.cnf',
|
||||
charset='utf8',
|
||||
sql_mode="ANSI,STRICT_TRANS_TABLES,TRADITIONAL")
|
||||
|
||||
def test_setoutputsize(self): pass
|
||||
def test_setoutputsize_basic(self): pass
|
||||
def test_nextset(self): pass
|
||||
|
||||
"""The tests on fetchone and fetchall and rowcount bogusly
|
||||
test for an exception if the statement cannot return a
|
||||
result set. MySQL always returns a result set; it's just that
|
||||
some things return empty result sets."""
|
||||
|
||||
def test_fetchall(self):
|
||||
con = self._connect()
|
||||
try:
|
||||
cur = con.cursor()
|
||||
# cursor.fetchall should raise an Error if called
|
||||
# without executing a query that may return rows (such
|
||||
# as a select)
|
||||
self.assertRaises(self.driver.Error, cur.fetchall)
|
||||
|
||||
self.executeDDL1(cur)
|
||||
for sql in self._populate():
|
||||
cur.execute(sql)
|
||||
|
||||
# cursor.fetchall should raise an Error if called
|
||||
# after executing a a statement that cannot return rows
|
||||
## self.assertRaises(self.driver.Error,cur.fetchall)
|
||||
|
||||
cur.execute('select name from %sbooze' % self.table_prefix)
|
||||
rows = cur.fetchall()
|
||||
self.assertTrue(cur.rowcount in (-1,len(self.samples)))
|
||||
self.assertEqual(len(rows),len(self.samples),
|
||||
'cursor.fetchall did not retrieve all rows'
|
||||
)
|
||||
rows = [r[0] for r in rows]
|
||||
rows.sort()
|
||||
for i in range(0,len(self.samples)):
|
||||
self.assertEqual(rows[i],self.samples[i],
|
||||
'cursor.fetchall retrieved incorrect rows'
|
||||
)
|
||||
rows = cur.fetchall()
|
||||
self.assertEqual(
|
||||
len(rows),0,
|
||||
'cursor.fetchall should return an empty list if called '
|
||||
'after the whole result set has been fetched'
|
||||
)
|
||||
self.assertTrue(cur.rowcount in (-1,len(self.samples)))
|
||||
|
||||
self.executeDDL2(cur)
|
||||
cur.execute('select name from %sbarflys' % self.table_prefix)
|
||||
rows = cur.fetchall()
|
||||
self.assertTrue(cur.rowcount in (-1,0))
|
||||
self.assertEqual(len(rows),0,
|
||||
'cursor.fetchall should return an empty list if '
|
||||
'a select query returns no rows'
|
||||
)
|
||||
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
def test_fetchone(self):
|
||||
con = self._connect()
|
||||
try:
|
||||
cur = con.cursor()
|
||||
|
||||
# cursor.fetchone should raise an Error if called before
|
||||
# executing a select-type query
|
||||
self.assertRaises(self.driver.Error,cur.fetchone)
|
||||
|
||||
# cursor.fetchone should raise an Error if called after
|
||||
# executing a query that cannnot return rows
|
||||
self.executeDDL1(cur)
|
||||
## self.assertRaises(self.driver.Error,cur.fetchone)
|
||||
|
||||
cur.execute('select name from %sbooze' % self.table_prefix)
|
||||
self.assertEqual(cur.fetchone(),None,
|
||||
'cursor.fetchone should return None if a query retrieves '
|
||||
'no rows'
|
||||
)
|
||||
self.assertTrue(cur.rowcount in (-1,0))
|
||||
|
||||
# cursor.fetchone should raise an Error if called after
|
||||
# executing a query that cannnot return rows
|
||||
cur.execute("insert into %sbooze values ('Victoria Bitter')" % (
|
||||
self.table_prefix
|
||||
))
|
||||
## self.assertRaises(self.driver.Error,cur.fetchone)
|
||||
|
||||
cur.execute('select name from %sbooze' % self.table_prefix)
|
||||
r = cur.fetchone()
|
||||
self.assertEqual(len(r),1,
|
||||
'cursor.fetchone should have retrieved a single row'
|
||||
)
|
||||
self.assertEqual(r[0],'Victoria Bitter',
|
||||
'cursor.fetchone retrieved incorrect data'
|
||||
)
|
||||
## self.assertEqual(cur.fetchone(),None,
|
||||
## 'cursor.fetchone should return None if no more rows available'
|
||||
## )
|
||||
self.assertTrue(cur.rowcount in (-1,1))
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
# Same complaint as for fetchall and fetchone
|
||||
def test_rowcount(self):
|
||||
con = self._connect()
|
||||
try:
|
||||
cur = con.cursor()
|
||||
self.executeDDL1(cur)
|
||||
## self.assertEqual(cur.rowcount,-1,
|
||||
## 'cursor.rowcount should be -1 after executing no-result '
|
||||
## 'statements'
|
||||
## )
|
||||
cur.execute("insert into %sbooze values ('Victoria Bitter')" % (
|
||||
self.table_prefix
|
||||
))
|
||||
## self.assertTrue(cur.rowcount in (-1,1),
|
||||
## 'cursor.rowcount should == number or rows inserted, or '
|
||||
## 'set to -1 after executing an insert statement'
|
||||
## )
|
||||
cur.execute("select name from %sbooze" % self.table_prefix)
|
||||
self.assertTrue(cur.rowcount in (-1,1),
|
||||
'cursor.rowcount should == number of rows returned, or '
|
||||
'set to -1 after executing a select statement'
|
||||
)
|
||||
self.executeDDL2(cur)
|
||||
## self.assertEqual(cur.rowcount,-1,
|
||||
## 'cursor.rowcount not being reset to -1 after executing '
|
||||
## 'no-result statements'
|
||||
## )
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
def test_callproc(self):
|
||||
pass # performed in test_MySQL_capabilities
|
||||
|
||||
def help_nextset_setUp(self,cur):
|
||||
''' Should create a procedure called deleteme
|
||||
that returns two result sets, first the
|
||||
number of rows in booze then "name from booze"
|
||||
'''
|
||||
sql="""
|
||||
create procedure deleteme()
|
||||
begin
|
||||
select count(*) from %(tp)sbooze;
|
||||
select name from %(tp)sbooze;
|
||||
end
|
||||
""" % dict(tp=self.table_prefix)
|
||||
cur.execute(sql)
|
||||
|
||||
def help_nextset_tearDown(self,cur):
|
||||
'If cleaning up is needed after nextSetTest'
|
||||
cur.execute("drop procedure deleteme")
|
||||
|
||||
def test_nextset(self):
|
||||
from warnings import warn
|
||||
con = self._connect()
|
||||
try:
|
||||
cur = con.cursor()
|
||||
if not hasattr(cur,'nextset'):
|
||||
return
|
||||
|
||||
try:
|
||||
self.executeDDL1(cur)
|
||||
sql=self._populate()
|
||||
for sql in self._populate():
|
||||
cur.execute(sql)
|
||||
|
||||
self.help_nextset_setUp(cur)
|
||||
|
||||
cur.callproc('deleteme')
|
||||
numberofrows=cur.fetchone()
|
||||
assert numberofrows[0]== len(self.samples)
|
||||
assert cur.nextset()
|
||||
names=cur.fetchall()
|
||||
assert len(names) == len(self.samples)
|
||||
s=cur.nextset()
|
||||
if s:
|
||||
empty = cur.fetchall()
|
||||
self.assertEquals(len(empty), 0,
|
||||
"non-empty result set after other result sets")
|
||||
#warn("Incompatibility: MySQL returns an empty result set for the CALL itself",
|
||||
# Warning)
|
||||
#assert s == None,'No more return sets, should return None'
|
||||
finally:
|
||||
self.help_nextset_tearDown(cur)
|
||||
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -1,85 +1,85 @@
|
||||
import unittest
|
||||
|
||||
import _mysql
|
||||
import MySQLdb
|
||||
from MySQLdb.constants import FIELD_TYPE
|
||||
|
||||
|
||||
class TestDBAPISet(unittest.TestCase):
|
||||
def test_set_equality(self):
|
||||
self.assertTrue(MySQLdb.STRING == MySQLdb.STRING)
|
||||
|
||||
def test_set_inequality(self):
|
||||
self.assertTrue(MySQLdb.STRING != MySQLdb.NUMBER)
|
||||
|
||||
def test_set_equality_membership(self):
|
||||
self.assertTrue(FIELD_TYPE.VAR_STRING == MySQLdb.STRING)
|
||||
|
||||
def test_set_inequality_membership(self):
|
||||
self.assertTrue(FIELD_TYPE.DATE != MySQLdb.STRING)
|
||||
|
||||
|
||||
class CoreModule(unittest.TestCase):
|
||||
"""Core _mysql module features."""
|
||||
|
||||
def test_NULL(self):
|
||||
"""Should have a NULL constant."""
|
||||
self.assertEqual(_mysql.NULL, 'NULL')
|
||||
|
||||
def test_version(self):
|
||||
"""Version information sanity."""
|
||||
self.assertTrue(isinstance(_mysql.__version__, str))
|
||||
|
||||
self.assertTrue(isinstance(_mysql.version_info, tuple))
|
||||
self.assertEqual(len(_mysql.version_info), 5)
|
||||
|
||||
def test_client_info(self):
|
||||
self.assertTrue(isinstance(_mysql.get_client_info(), str))
|
||||
|
||||
def test_thread_safe(self):
|
||||
self.assertTrue(isinstance(_mysql.thread_safe(), int))
|
||||
|
||||
|
||||
class CoreAPI(unittest.TestCase):
|
||||
"""Test _mysql interaction internals."""
|
||||
|
||||
def setUp(self):
|
||||
self.conn = _mysql.connect(db='test', host='127.0.0.1', user='test') #read_default_file="~/.my.cnf")
|
||||
|
||||
def tearDown(self):
|
||||
self.conn.close()
|
||||
|
||||
def test_thread_id(self):
|
||||
tid = self.conn.thread_id()
|
||||
self.assertTrue(isinstance(tid, int),
|
||||
"thread_id didn't return an int.")
|
||||
|
||||
self.assertRaises(TypeError, self.conn.thread_id, ('evil',),
|
||||
"thread_id shouldn't accept arguments.")
|
||||
|
||||
def test_affected_rows(self):
|
||||
self.assertEquals(self.conn.affected_rows(), 0,
|
||||
"Should return 0 before we do anything.")
|
||||
|
||||
|
||||
#def test_debug(self):
|
||||
## FIXME Only actually tests if you lack SUPER
|
||||
#self.assertRaises(MySQLdb.OperationalError,
|
||||
#self.conn.dump_debug_info)
|
||||
|
||||
def test_charset_name(self):
|
||||
self.assertTrue(isinstance(self.conn.character_set_name(), str),
|
||||
"Should return a string.")
|
||||
|
||||
def test_host_info(self):
|
||||
self.assertTrue(isinstance(self.conn.get_host_info(), str),
|
||||
"Should return a string.")
|
||||
|
||||
def test_proto_info(self):
|
||||
self.assertTrue(isinstance(self.conn.get_proto_info(), int),
|
||||
"Should return an int.")
|
||||
|
||||
def test_server_info(self):
|
||||
self.assertTrue(isinstance(self.conn.get_server_info(), str),
|
||||
"Should return an str.")
|
||||
|
||||
import unittest
|
||||
|
||||
import _mysql
|
||||
import MySQLdb
|
||||
from MySQLdb.constants import FIELD_TYPE
|
||||
|
||||
|
||||
class TestDBAPISet(unittest.TestCase):
|
||||
def test_set_equality(self):
|
||||
self.assertTrue(MySQLdb.STRING == MySQLdb.STRING)
|
||||
|
||||
def test_set_inequality(self):
|
||||
self.assertTrue(MySQLdb.STRING != MySQLdb.NUMBER)
|
||||
|
||||
def test_set_equality_membership(self):
|
||||
self.assertTrue(FIELD_TYPE.VAR_STRING == MySQLdb.STRING)
|
||||
|
||||
def test_set_inequality_membership(self):
|
||||
self.assertTrue(FIELD_TYPE.DATE != MySQLdb.STRING)
|
||||
|
||||
|
||||
class CoreModule(unittest.TestCase):
|
||||
"""Core _mysql module features."""
|
||||
|
||||
def test_NULL(self):
|
||||
"""Should have a NULL constant."""
|
||||
self.assertEqual(_mysql.NULL, 'NULL')
|
||||
|
||||
def test_version(self):
|
||||
"""Version information sanity."""
|
||||
self.assertTrue(isinstance(_mysql.__version__, str))
|
||||
|
||||
self.assertTrue(isinstance(_mysql.version_info, tuple))
|
||||
self.assertEqual(len(_mysql.version_info), 5)
|
||||
|
||||
def test_client_info(self):
|
||||
self.assertTrue(isinstance(_mysql.get_client_info(), str))
|
||||
|
||||
def test_thread_safe(self):
|
||||
self.assertTrue(isinstance(_mysql.thread_safe(), int))
|
||||
|
||||
|
||||
class CoreAPI(unittest.TestCase):
|
||||
"""Test _mysql interaction internals."""
|
||||
|
||||
def setUp(self):
|
||||
self.conn = _mysql.connect(db='test', host='127.0.0.1', user='test') #read_default_file="~/.my.cnf")
|
||||
|
||||
def tearDown(self):
|
||||
self.conn.close()
|
||||
|
||||
def test_thread_id(self):
|
||||
tid = self.conn.thread_id()
|
||||
self.assertTrue(isinstance(tid, int),
|
||||
"thread_id didn't return an int.")
|
||||
|
||||
self.assertRaises(TypeError, self.conn.thread_id, ('evil',),
|
||||
"thread_id shouldn't accept arguments.")
|
||||
|
||||
def test_affected_rows(self):
|
||||
self.assertEquals(self.conn.affected_rows(), 0,
|
||||
"Should return 0 before we do anything.")
|
||||
|
||||
|
||||
#def test_debug(self):
|
||||
## FIXME Only actually tests if you lack SUPER
|
||||
#self.assertRaises(MySQLdb.OperationalError,
|
||||
#self.conn.dump_debug_info)
|
||||
|
||||
def test_charset_name(self):
|
||||
self.assertTrue(isinstance(self.conn.character_set_name(), str),
|
||||
"Should return a string.")
|
||||
|
||||
def test_host_info(self):
|
||||
self.assertTrue(isinstance(self.conn.get_host_info(), str),
|
||||
"Should return a string.")
|
||||
|
||||
def test_proto_info(self):
|
||||
self.assertTrue(isinstance(self.conn.get_proto_info(), int),
|
||||
"Should return an int.")
|
||||
|
||||
def test_server_info(self):
|
||||
self.assertTrue(isinstance(self.conn.get_server_info(), str),
|
||||
"Should return an str.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user