incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [2/4] git commit: Removing pymysql and including it as setup dependency
Date Sat, 04 Aug 2012 12:00:57 GMT
Removing pymysql and including it as setup dependency


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/60cd6538
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/60cd6538
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/60cd6538

Branch: refs/heads/master
Commit: 60cd65382f91ff8c3b35bddc20618403a71477bd
Parents: 37aeff8
Author: Prasanna Santhanam <Prasanna.Santhanam@citrix.com>
Authored: Sat Aug 4 17:16:12 2012 +0530
Committer: Prasanna Santhanam <Prasanna.Santhanam@citrix.com>
Committed: Sat Aug 4 17:17:11 2012 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/pymysql/__init__.py            |  131 --
 tools/marvin/marvin/pymysql/charset.py             |  174 ---
 tools/marvin/marvin/pymysql/connections.py         |  928 ---------------
 tools/marvin/marvin/pymysql/constants/CLIENT.py    |   20 -
 tools/marvin/marvin/pymysql/constants/COMMAND.py   |   23 -
 tools/marvin/marvin/pymysql/constants/ER.py        |  472 --------
 .../marvin/marvin/pymysql/constants/FIELD_TYPE.py  |   32 -
 tools/marvin/marvin/pymysql/constants/FLAG.py      |   15 -
 .../marvin/pymysql/constants/SERVER_STATUS.py      |   12 -
 tools/marvin/marvin/pymysql/converters.py          |  348 ------
 tools/marvin/marvin/pymysql/cursors.py             |  297 -----
 tools/marvin/marvin/pymysql/err.py                 |  147 ---
 tools/marvin/marvin/pymysql/tests/__init__.py      |   13 -
 tools/marvin/marvin/pymysql/tests/base.py          |   20 -
 .../marvin/marvin/pymysql/tests/test_DictCursor.py |   56 -
 tools/marvin/marvin/pymysql/tests/test_basic.py    |  193 ---
 tools/marvin/marvin/pymysql/tests/test_example.py  |   32 -
 tools/marvin/marvin/pymysql/tests/test_issues.py   |  268 -----
 .../marvin/pymysql/tests/thirdparty/__init__.py    |    5 -
 .../tests/thirdparty/test_MySQLdb/__init__.py      |    7 -
 .../tests/thirdparty/test_MySQLdb/capabilities.py  |  292 -----
 .../tests/thirdparty/test_MySQLdb/dbapi20.py       |  853 -------------
 .../test_MySQLdb/test_MySQLdb_capabilities.py      |  115 --
 .../test_MySQLdb/test_MySQLdb_dbapi20.py           |  205 ----
 .../test_MySQLdb/test_MySQLdb_nonstandard.py       |   90 --
 tools/marvin/marvin/pymysql/times.py               |   16 -
 tools/marvin/marvin/pymysql/util.py                |   19 -
 tools/marvin/setup.py                              |    3 +-
 28 files changed, 2 insertions(+), 4784 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/__init__.py b/tools/marvin/marvin/pymysql/__init__.py
deleted file mode 100644
index 903107e..0000000
--- a/tools/marvin/marvin/pymysql/__init__.py
+++ /dev/null
@@ -1,131 +0,0 @@
-'''
-PyMySQL: A pure-Python drop-in replacement for MySQLdb.
-
-Copyright (c) 2010 PyMySQL contributors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-'''
-
-VERSION = (0, 4, None)
-
-from constants import FIELD_TYPE
-from converters import escape_dict, escape_sequence, escape_string
-from err import Warning, Error, InterfaceError, DataError, \
-     DatabaseError, OperationalError, IntegrityError, InternalError, \
-     NotSupportedError, ProgrammingError, MySQLError
-from times import Date, Time, Timestamp, \
-    DateFromTicks, TimeFromTicks, TimestampFromTicks
-
-import sys
-
-try:
-    frozenset
-except NameError:
-    from sets import ImmutableSet as frozenset
-    try:
-        from sets import BaseSet as set
-    except ImportError:
-        from sets import Set as set
-
-threadsafety = 1
-apilevel = "2.0"
-paramstyle = "format"
-
-class DBAPISet(frozenset):
-
-
-    def __ne__(self, other):
-        if isinstance(other, set):
-            return super(DBAPISet, self).__ne__(self, other)
-        else:
-            return other not in self
-
-    def __eq__(self, other):
-        if isinstance(other, frozenset):
-            return frozenset.__eq__(self, other)
-        else:
-            return other in self
-
-    def __hash__(self):
-        return frozenset.__hash__(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 Binary(x):
-    """Return x as a binary type."""
-    return str(x)
-
-def Connect(*args, **kwargs):
-    """
-    Connect to the database; see connections.Connection.__init__() for
-    more information.
-    """
-    from connections import Connection
-    return Connection(*args, **kwargs)
-
-def get_client_info():  # for MySQLdb compatibility
-  return '%s.%s.%s' % VERSION
-
-connect = Connection = Connect
-
-# we include a doctored version_info here for MySQLdb compatibility
-version_info = (1,2,2,"final",0)
-
-NULL = "NULL"
-
-__version__ = get_client_info()
-
-def thread_safe():
-    return True # match MySQLdb.thread_safe()
-
-def install_as_MySQLdb():
-    """
-    After this function is called, any application that imports MySQLdb or
-    _mysql will unwittingly actually use 
-    """
-    sys.modules["MySQLdb"] = sys.modules["_mysql"] = sys.modules["pymysql"]
-
-__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',
-    'escape_dict', 'escape_sequence', 'escape_string', 'get_client_info',
-    'paramstyle', 'threadsafety', 'version_info',
-
-    "install_as_MySQLdb",
-
-    "NULL","__version__",
-    ]

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/charset.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/charset.py b/tools/marvin/marvin/pymysql/charset.py
deleted file mode 100644
index 10a91bd..0000000
--- a/tools/marvin/marvin/pymysql/charset.py
+++ /dev/null
@@ -1,174 +0,0 @@
-MBLENGTH = {
-        8:1,
-        33:3,
-        88:2,
-        91:2
-        }
-
-class Charset:
-    def __init__(self, id, name, collation, is_default):
-        self.id, self.name, self.collation = id, name, collation
-        self.is_default = is_default == 'Yes'
-
-class Charsets:
-    def __init__(self):
-        self._by_id = {}
-
-    def add(self, c):
-        self._by_id[c.id] = c
-
-    def by_id(self, id):
-        return self._by_id[id]
-
-    def by_name(self, name):
-        for c in self._by_id.values():
-            if c.name == name and c.is_default:
-                return c
-
-_charsets = Charsets()
-"""
-Generated with:
-
-mysql -N -s -e "select id, character_set_name, collation_name, is_default
-from information_schema.collations order by id;" | python -c "import sys
-for l in sys.stdin.readlines():
-        id, name, collation, is_default  = l.split(chr(9))
-        print '_charsets.add(Charset(%s, \'%s\', \'%s\', \'%s\'))' \
-                % (id, name, collation, is_default.strip())
-"
-
-"""
-_charsets.add(Charset(1, 'big5', 'big5_chinese_ci', 'Yes'))
-_charsets.add(Charset(2, 'latin2', 'latin2_czech_cs', ''))
-_charsets.add(Charset(3, 'dec8', 'dec8_swedish_ci', 'Yes'))
-_charsets.add(Charset(4, 'cp850', 'cp850_general_ci', 'Yes'))
-_charsets.add(Charset(5, 'latin1', 'latin1_german1_ci', ''))
-_charsets.add(Charset(6, 'hp8', 'hp8_english_ci', 'Yes'))
-_charsets.add(Charset(7, 'koi8r', 'koi8r_general_ci', 'Yes'))
-_charsets.add(Charset(8, 'latin1', 'latin1_swedish_ci', 'Yes'))
-_charsets.add(Charset(9, 'latin2', 'latin2_general_ci', 'Yes'))
-_charsets.add(Charset(10, 'swe7', 'swe7_swedish_ci', 'Yes'))
-_charsets.add(Charset(11, 'ascii', 'ascii_general_ci', 'Yes'))
-_charsets.add(Charset(12, 'ujis', 'ujis_japanese_ci', 'Yes'))
-_charsets.add(Charset(13, 'sjis', 'sjis_japanese_ci', 'Yes'))
-_charsets.add(Charset(14, 'cp1251', 'cp1251_bulgarian_ci', ''))
-_charsets.add(Charset(15, 'latin1', 'latin1_danish_ci', ''))
-_charsets.add(Charset(16, 'hebrew', 'hebrew_general_ci', 'Yes'))
-_charsets.add(Charset(18, 'tis620', 'tis620_thai_ci', 'Yes'))
-_charsets.add(Charset(19, 'euckr', 'euckr_korean_ci', 'Yes'))
-_charsets.add(Charset(20, 'latin7', 'latin7_estonian_cs', ''))
-_charsets.add(Charset(21, 'latin2', 'latin2_hungarian_ci', ''))
-_charsets.add(Charset(22, 'koi8u', 'koi8u_general_ci', 'Yes'))
-_charsets.add(Charset(23, 'cp1251', 'cp1251_ukrainian_ci', ''))
-_charsets.add(Charset(24, 'gb2312', 'gb2312_chinese_ci', 'Yes'))
-_charsets.add(Charset(25, 'greek', 'greek_general_ci', 'Yes'))
-_charsets.add(Charset(26, 'cp1250', 'cp1250_general_ci', 'Yes'))
-_charsets.add(Charset(27, 'latin2', 'latin2_croatian_ci', ''))
-_charsets.add(Charset(28, 'gbk', 'gbk_chinese_ci', 'Yes'))
-_charsets.add(Charset(29, 'cp1257', 'cp1257_lithuanian_ci', ''))
-_charsets.add(Charset(30, 'latin5', 'latin5_turkish_ci', 'Yes'))
-_charsets.add(Charset(31, 'latin1', 'latin1_german2_ci', ''))
-_charsets.add(Charset(32, 'armscii8', 'armscii8_general_ci', 'Yes'))
-_charsets.add(Charset(33, 'utf8', 'utf8_general_ci', 'Yes'))
-_charsets.add(Charset(34, 'cp1250', 'cp1250_czech_cs', ''))
-_charsets.add(Charset(35, 'ucs2', 'ucs2_general_ci', 'Yes'))
-_charsets.add(Charset(36, 'cp866', 'cp866_general_ci', 'Yes'))
-_charsets.add(Charset(37, 'keybcs2', 'keybcs2_general_ci', 'Yes'))
-_charsets.add(Charset(38, 'macce', 'macce_general_ci', 'Yes'))
-_charsets.add(Charset(39, 'macroman', 'macroman_general_ci', 'Yes'))
-_charsets.add(Charset(40, 'cp852', 'cp852_general_ci', 'Yes'))
-_charsets.add(Charset(41, 'latin7', 'latin7_general_ci', 'Yes'))
-_charsets.add(Charset(42, 'latin7', 'latin7_general_cs', ''))
-_charsets.add(Charset(43, 'macce', 'macce_bin', ''))
-_charsets.add(Charset(44, 'cp1250', 'cp1250_croatian_ci', ''))
-_charsets.add(Charset(47, 'latin1', 'latin1_bin', ''))
-_charsets.add(Charset(48, 'latin1', 'latin1_general_ci', ''))
-_charsets.add(Charset(49, 'latin1', 'latin1_general_cs', ''))
-_charsets.add(Charset(50, 'cp1251', 'cp1251_bin', ''))
-_charsets.add(Charset(51, 'cp1251', 'cp1251_general_ci', 'Yes'))
-_charsets.add(Charset(52, 'cp1251', 'cp1251_general_cs', ''))
-_charsets.add(Charset(53, 'macroman', 'macroman_bin', ''))
-_charsets.add(Charset(57, 'cp1256', 'cp1256_general_ci', 'Yes'))
-_charsets.add(Charset(58, 'cp1257', 'cp1257_bin', ''))
-_charsets.add(Charset(59, 'cp1257', 'cp1257_general_ci', 'Yes'))
-_charsets.add(Charset(63, 'binary', 'binary', 'Yes'))
-_charsets.add(Charset(64, 'armscii8', 'armscii8_bin', ''))
-_charsets.add(Charset(65, 'ascii', 'ascii_bin', ''))
-_charsets.add(Charset(66, 'cp1250', 'cp1250_bin', ''))
-_charsets.add(Charset(67, 'cp1256', 'cp1256_bin', ''))
-_charsets.add(Charset(68, 'cp866', 'cp866_bin', ''))
-_charsets.add(Charset(69, 'dec8', 'dec8_bin', ''))
-_charsets.add(Charset(70, 'greek', 'greek_bin', ''))
-_charsets.add(Charset(71, 'hebrew', 'hebrew_bin', ''))
-_charsets.add(Charset(72, 'hp8', 'hp8_bin', ''))
-_charsets.add(Charset(73, 'keybcs2', 'keybcs2_bin', ''))
-_charsets.add(Charset(74, 'koi8r', 'koi8r_bin', ''))
-_charsets.add(Charset(75, 'koi8u', 'koi8u_bin', ''))
-_charsets.add(Charset(77, 'latin2', 'latin2_bin', ''))
-_charsets.add(Charset(78, 'latin5', 'latin5_bin', ''))
-_charsets.add(Charset(79, 'latin7', 'latin7_bin', ''))
-_charsets.add(Charset(80, 'cp850', 'cp850_bin', ''))
-_charsets.add(Charset(81, 'cp852', 'cp852_bin', ''))
-_charsets.add(Charset(82, 'swe7', 'swe7_bin', ''))
-_charsets.add(Charset(83, 'utf8', 'utf8_bin', ''))
-_charsets.add(Charset(84, 'big5', 'big5_bin', ''))
-_charsets.add(Charset(85, 'euckr', 'euckr_bin', ''))
-_charsets.add(Charset(86, 'gb2312', 'gb2312_bin', ''))
-_charsets.add(Charset(87, 'gbk', 'gbk_bin', ''))
-_charsets.add(Charset(88, 'sjis', 'sjis_bin', ''))
-_charsets.add(Charset(89, 'tis620', 'tis620_bin', ''))
-_charsets.add(Charset(90, 'ucs2', 'ucs2_bin', ''))
-_charsets.add(Charset(91, 'ujis', 'ujis_bin', ''))
-_charsets.add(Charset(92, 'geostd8', 'geostd8_general_ci', 'Yes'))
-_charsets.add(Charset(93, 'geostd8', 'geostd8_bin', ''))
-_charsets.add(Charset(94, 'latin1', 'latin1_spanish_ci', ''))
-_charsets.add(Charset(95, 'cp932', 'cp932_japanese_ci', 'Yes'))
-_charsets.add(Charset(96, 'cp932', 'cp932_bin', ''))
-_charsets.add(Charset(97, 'eucjpms', 'eucjpms_japanese_ci', 'Yes'))
-_charsets.add(Charset(98, 'eucjpms', 'eucjpms_bin', ''))
-_charsets.add(Charset(99, 'cp1250', 'cp1250_polish_ci', ''))
-_charsets.add(Charset(128, 'ucs2', 'ucs2_unicode_ci', ''))
-_charsets.add(Charset(129, 'ucs2', 'ucs2_icelandic_ci', ''))
-_charsets.add(Charset(130, 'ucs2', 'ucs2_latvian_ci', ''))
-_charsets.add(Charset(131, 'ucs2', 'ucs2_romanian_ci', ''))
-_charsets.add(Charset(132, 'ucs2', 'ucs2_slovenian_ci', ''))
-_charsets.add(Charset(133, 'ucs2', 'ucs2_polish_ci', ''))
-_charsets.add(Charset(134, 'ucs2', 'ucs2_estonian_ci', ''))
-_charsets.add(Charset(135, 'ucs2', 'ucs2_spanish_ci', ''))
-_charsets.add(Charset(136, 'ucs2', 'ucs2_swedish_ci', ''))
-_charsets.add(Charset(137, 'ucs2', 'ucs2_turkish_ci', ''))
-_charsets.add(Charset(138, 'ucs2', 'ucs2_czech_ci', ''))
-_charsets.add(Charset(139, 'ucs2', 'ucs2_danish_ci', ''))
-_charsets.add(Charset(140, 'ucs2', 'ucs2_lithuanian_ci', ''))
-_charsets.add(Charset(141, 'ucs2', 'ucs2_slovak_ci', ''))
-_charsets.add(Charset(142, 'ucs2', 'ucs2_spanish2_ci', ''))
-_charsets.add(Charset(143, 'ucs2', 'ucs2_roman_ci', ''))
-_charsets.add(Charset(144, 'ucs2', 'ucs2_persian_ci', ''))
-_charsets.add(Charset(145, 'ucs2', 'ucs2_esperanto_ci', ''))
-_charsets.add(Charset(146, 'ucs2', 'ucs2_hungarian_ci', ''))
-_charsets.add(Charset(192, 'utf8', 'utf8_unicode_ci', ''))
-_charsets.add(Charset(193, 'utf8', 'utf8_icelandic_ci', ''))
-_charsets.add(Charset(194, 'utf8', 'utf8_latvian_ci', ''))
-_charsets.add(Charset(195, 'utf8', 'utf8_romanian_ci', ''))
-_charsets.add(Charset(196, 'utf8', 'utf8_slovenian_ci', ''))
-_charsets.add(Charset(197, 'utf8', 'utf8_polish_ci', ''))
-_charsets.add(Charset(198, 'utf8', 'utf8_estonian_ci', ''))
-_charsets.add(Charset(199, 'utf8', 'utf8_spanish_ci', ''))
-_charsets.add(Charset(200, 'utf8', 'utf8_swedish_ci', ''))
-_charsets.add(Charset(201, 'utf8', 'utf8_turkish_ci', ''))
-_charsets.add(Charset(202, 'utf8', 'utf8_czech_ci', ''))
-_charsets.add(Charset(203, 'utf8', 'utf8_danish_ci', ''))
-_charsets.add(Charset(204, 'utf8', 'utf8_lithuanian_ci', ''))
-_charsets.add(Charset(205, 'utf8', 'utf8_slovak_ci', ''))
-_charsets.add(Charset(206, 'utf8', 'utf8_spanish2_ci', ''))
-_charsets.add(Charset(207, 'utf8', 'utf8_roman_ci', ''))
-_charsets.add(Charset(208, 'utf8', 'utf8_persian_ci', ''))
-_charsets.add(Charset(209, 'utf8', 'utf8_esperanto_ci', ''))
-_charsets.add(Charset(210, 'utf8', 'utf8_hungarian_ci', ''))
-
-def charset_by_name(name):
-    return _charsets.by_name(name)
-
-def charset_by_id(id):
-    return _charsets.by_id(id)
-

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/connections.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/connections.py b/tools/marvin/marvin/pymysql/connections.py
deleted file mode 100644
index 8897644..0000000
--- a/tools/marvin/marvin/pymysql/connections.py
+++ /dev/null
@@ -1,928 +0,0 @@
-# Python implementation of the MySQL client-server protocol
-#   http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol
-
-try:
-    import hashlib
-    sha_new = lambda *args, **kwargs: hashlib.new("sha1", *args, **kwargs)
-except ImportError:
-    import sha
-    sha_new = sha.new
-
-import socket
-try:
-    import ssl
-    SSL_ENABLED = True
-except ImportError:
-    SSL_ENABLED = False
-
-import struct
-import sys
-import os
-import ConfigParser
-
-try:
-    import cStringIO as StringIO
-except ImportError:
-    import StringIO
-
-from charset import MBLENGTH, charset_by_name, charset_by_id
-from cursors import Cursor
-from constants import FIELD_TYPE, FLAG
-from constants import SERVER_STATUS
-from constants.CLIENT import *
-from constants.COMMAND import *
-from util import join_bytes, byte2int, int2byte
-from converters import escape_item, encoders, decoders
-from err import raise_mysql_exception, Warning, Error, \
-     InterfaceError, DataError, DatabaseError, OperationalError, \
-     IntegrityError, InternalError, NotSupportedError, ProgrammingError
-
-DEBUG = False
-
-NULL_COLUMN = 251
-UNSIGNED_CHAR_COLUMN = 251
-UNSIGNED_SHORT_COLUMN = 252
-UNSIGNED_INT24_COLUMN = 253
-UNSIGNED_INT64_COLUMN = 254
-UNSIGNED_CHAR_LENGTH = 1
-UNSIGNED_SHORT_LENGTH = 2
-UNSIGNED_INT24_LENGTH = 3
-UNSIGNED_INT64_LENGTH = 8
-
-DEFAULT_CHARSET = 'latin1'
-
-
-def dump_packet(data):
-    
-    def is_ascii(data):
-        if byte2int(data) >= 65 and byte2int(data) <= 122: #data.isalnum():
-            return data
-        return '.'
-    print "packet length %d" % len(data)
-    print "method call[1]: %s" % sys._getframe(1).f_code.co_name
-    print "method call[2]: %s" % sys._getframe(2).f_code.co_name
-    print "method call[3]: %s" % sys._getframe(3).f_code.co_name
-    print "method call[4]: %s" % sys._getframe(4).f_code.co_name
-    print "method call[5]: %s" % sys._getframe(5).f_code.co_name
-    print "-" * 88
-    dump_data = [data[i:i+16] for i in xrange(len(data)) if i%16 == 0]
-    for d in dump_data:
-        print ' '.join(map(lambda x:"%02X" % byte2int(x), d)) + \
-                '   ' * (16 - len(d)) + ' ' * 2 + \
-                ' '.join(map(lambda x:"%s" % is_ascii(x), d))
-    print "-" * 88
-    print ""
-
-def _scramble(password, message):
-    if password == None or len(password) == 0:
-        return int2byte(0)
-    if DEBUG: print 'password=' + password
-    stage1 = sha_new(password).digest()
-    stage2 = sha_new(stage1).digest()
-    s = sha_new()
-    s.update(message)
-    s.update(stage2)
-    result = s.digest()
-    return _my_crypt(result, stage1)
-
-def _my_crypt(message1, message2):
-    length = len(message1)
-    result = struct.pack('B', length)
-    for i in xrange(length):
-        x = (struct.unpack('B', message1[i:i+1])[0] ^ \
-             struct.unpack('B', message2[i:i+1])[0])
-        result += struct.pack('B', x)
-    return result
-
-# old_passwords support ported from libmysql/password.c
-SCRAMBLE_LENGTH_323 = 8
-
-class RandStruct_323(object):
-    def __init__(self, seed1, seed2):
-        self.max_value = 0x3FFFFFFFL
-        self.seed1 = seed1 % self.max_value
-        self.seed2 = seed2 % self.max_value
-
-    def my_rnd(self):
-        self.seed1 = (self.seed1 * 3L + self.seed2) % self.max_value
-        self.seed2 = (self.seed1 + self.seed2 + 33L) % self.max_value
-        return float(self.seed1) / float(self.max_value)
-
-def _scramble_323(password, message):
-    hash_pass = _hash_password_323(password)
-    hash_message = _hash_password_323(message[:SCRAMBLE_LENGTH_323])
-    hash_pass_n = struct.unpack(">LL", hash_pass)
-    hash_message_n = struct.unpack(">LL", hash_message)
-
-    rand_st = RandStruct_323(hash_pass_n[0] ^ hash_message_n[0],
-                             hash_pass_n[1] ^ hash_message_n[1])
-    outbuf = StringIO.StringIO()
-    for _ in xrange(min(SCRAMBLE_LENGTH_323, len(message))):
-        outbuf.write(int2byte(int(rand_st.my_rnd() * 31) + 64))
-    extra = int2byte(int(rand_st.my_rnd() * 31))
-    out = outbuf.getvalue()
-    outbuf = StringIO.StringIO()
-    for c in out:
-        outbuf.write(int2byte(byte2int(c) ^ byte2int(extra)))
-    return outbuf.getvalue()
-
-def _hash_password_323(password):
-    nr = 1345345333L
-    add = 7L
-    nr2 = 0x12345671L
-
-    for c in [byte2int(x) for x in password if x not in (' ', '\t')]:
-        nr^= (((nr & 63)+add)*c)+ (nr << 8) & 0xFFFFFFFF
-        nr2= (nr2 + ((nr2 << 8) ^ nr)) & 0xFFFFFFFF
-        add= (add + c) & 0xFFFFFFFF
-
-    r1 = nr & ((1L << 31) - 1L) # kill sign bits
-    r2 = nr2 & ((1L << 31) - 1L)
-
-    # pack
-    return struct.pack(">LL", r1, r2)
-
-def pack_int24(n):
-    return struct.pack('BBB', n&0xFF, (n>>8)&0xFF, (n>>16)&0xFF)
-
-def unpack_uint16(n):
-  return struct.unpack('<H', n[0:2])[0]
-
-
-# TODO: stop using bit-shifting in these functions...
-# TODO: rename to "uint" to make it clear they're unsigned...
-def unpack_int24(n):
-    return struct.unpack('B',n[0])[0] + (struct.unpack('B', n[1])[0] << 8) +\
-        (struct.unpack('B',n[2])[0] << 16)
-
-def unpack_int32(n):
-    return struct.unpack('B',n[0])[0] + (struct.unpack('B', n[1])[0] << 8) +\
-        (struct.unpack('B',n[2])[0] << 16) + (struct.unpack('B', n[3])[0] << 24)
-
-def unpack_int64(n):
-    return struct.unpack('B',n[0])[0] + (struct.unpack('B', n[1])[0]<<8) +\
-    (struct.unpack('B',n[2])[0] << 16) + (struct.unpack('B',n[3])[0]<<24)+\
-    (struct.unpack('B',n[4])[0] << 32) + (struct.unpack('B',n[5])[0]<<40)+\
-    (struct.unpack('B',n[6])[0] << 48) + (struct.unpack('B',n[7])[0]<<56)
-
-def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
-    err = errorclass, errorvalue
-    if DEBUG:
-        raise
-
-    if cursor:
-        cursor.messages.append(err)
-    else:
-        connection.messages.append(err)
-    del cursor
-    del connection
-
-    if not issubclass(errorclass, Error):
-        raise Error(errorclass, errorvalue)
-    else:
-        raise errorclass, errorvalue
-
-
-class MysqlPacket(object):
-  """Representation of a MySQL response packet.  Reads in the packet
-  from the network socket, removes packet header and provides an interface
-  for reading/parsing the packet results."""
-
-  def __init__(self, connection):
-    self.connection = connection
-    self.__position = 0
-    self.__recv_packet()
-
-  def __recv_packet(self):
-    """Parse the packet header and read entire packet payload into buffer."""
-    packet_header = self.connection.rfile.read(4)
-    if len(packet_header) < 4:
-        raise OperationalError(2013, "Lost connection to MySQL server during query")
-
-    if DEBUG: dump_packet(packet_header)
-    packet_length_bin = packet_header[:3]
-    self.__packet_number = byte2int(packet_header[3])
-    # TODO: check packet_num is correct (+1 from last packet)
-
-    bin_length = packet_length_bin + int2byte(0)  # pad little-endian number
-    bytes_to_read = struct.unpack('<I', bin_length)[0]
-    recv_data = self.connection.rfile.read(bytes_to_read)
-    if len(recv_data) < bytes_to_read:
-        raise OperationalError(2013, "Lost connection to MySQL server during query")
-    if DEBUG: dump_packet(recv_data)
-    self.__data = recv_data
-
-  def packet_number(self): return self.__packet_number
-
-  def get_all_data(self): return self.__data
-
-  def read(self, size):
-    """Read the first 'size' bytes in packet and advance cursor past them."""
-    result = self.peek(size)
-    self.advance(size)
-    return result
-
-  def read_all(self):
-    """Read all remaining data in the packet.
-
-    (Subsequent read() or peek() will return errors.)
-    """
-    result = self.__data[self.__position:]
-    self.__position = None  # ensure no subsequent read() or peek()
-    return result
-
-  def advance(self, length):
-    """Advance the cursor in data buffer 'length' bytes."""
-    new_position = self.__position + length
-    if new_position < 0 or new_position > len(self.__data):
-      raise Exception('Invalid advance amount (%s) for cursor.  '
-                      'Position=%s' % (length, new_position))
-    self.__position = new_position
-
-  def rewind(self, position=0):
-    """Set the position of the data buffer cursor to 'position'."""
-    if position < 0 or position > len(self.__data):
-      raise Exception("Invalid position to rewind cursor to: %s." % position)
-    self.__position = position
-
-  def peek(self, size):
-    """Look at the first 'size' bytes in packet without moving cursor."""
-    result = self.__data[self.__position:(self.__position+size)]
-    if len(result) != size:
-      error = ('Result length not requested length:\n'
-               'Expected=%s.  Actual=%s.  Position: %s.  Data Length: %s'
-               % (size, len(result), self.__position, len(self.__data)))
-      if DEBUG:
-        print error
-        self.dump()
-      raise AssertionError(error)
-    return result
-
-  def get_bytes(self, position, length=1):
-    """Get 'length' bytes starting at 'position'.
-
-    Position is start of payload (first four packet header bytes are not
-    included) starting at index '0'.
-
-    No error checking is done.  If requesting outside end of buffer
-    an empty string (or string shorter than 'length') may be returned!
-    """
-    return self.__data[position:(position+length)]
-
-  def read_length_coded_binary(self):
-    """Read a 'Length Coded Binary' number from the data buffer.
-
-    Length coded numbers can be anywhere from 1 to 9 bytes depending
-    on the value of the first byte.
-    """
-    c = byte2int(self.read(1))
-    if c == NULL_COLUMN:
-      return None
-    if c < UNSIGNED_CHAR_COLUMN:
-      return c
-    elif c == UNSIGNED_SHORT_COLUMN:
-      return unpack_uint16(self.read(UNSIGNED_SHORT_LENGTH))
-    elif c == UNSIGNED_INT24_COLUMN:
-      return unpack_int24(self.read(UNSIGNED_INT24_LENGTH))
-    elif c == UNSIGNED_INT64_COLUMN:
-      # TODO: what was 'longlong'?  confirm it wasn't used?
-      return unpack_int64(self.read(UNSIGNED_INT64_LENGTH))
-
-  def read_length_coded_string(self):
-    """Read a 'Length Coded String' from the data buffer.
-
-    A 'Length Coded String' consists first of a length coded
-    (unsigned, positive) integer represented in 1-9 bytes followed by
-    that many bytes of binary data.  (For example "cat" would be "3cat".)
-    """
-    length = self.read_length_coded_binary()
-    if length is None:
-        return None
-    return self.read(length)
-
-  def is_ok_packet(self):
-    return byte2int(self.get_bytes(0)) == 0
-
-  def is_eof_packet(self):
-    return byte2int(self.get_bytes(0)) == 254  # 'fe'
-
-  def is_resultset_packet(self):
-    field_count = byte2int(self.get_bytes(0))
-    return field_count >= 1 and field_count <= 250
-
-  def is_error_packet(self):
-    return byte2int(self.get_bytes(0)) == 255
-
-  def check_error(self):
-    if self.is_error_packet():
-      self.rewind()
-      self.advance(1)  # field_count == error (we already know that)
-      errno = unpack_uint16(self.read(2))
-      if DEBUG: print "errno = %d" % errno
-      raise_mysql_exception(self.__data)
-
-  def dump(self):
-    dump_packet(self.__data)
-
-
-class FieldDescriptorPacket(MysqlPacket):
-  """A MysqlPacket that represents a specific column's metadata in the result.
-
-  Parsing is automatically done and the results are exported via public
-  attributes on the class such as: db, table_name, name, length, type_code.
-  """
-
-  def __init__(self, *args):
-    MysqlPacket.__init__(self, *args)
-    self.__parse_field_descriptor()
-
-  def __parse_field_descriptor(self):
-    """Parse the 'Field Descriptor' (Metadata) packet.
-
-    This is compatible with MySQL 4.1+ (not compatible with MySQL 4.0).
-    """
-    self.catalog = self.read_length_coded_string()
-    self.db = self.read_length_coded_string()
-    self.table_name = self.read_length_coded_string()
-    self.org_table = self.read_length_coded_string()
-    self.name = self.read_length_coded_string().decode(self.connection.charset)
-    self.org_name = self.read_length_coded_string()
-    self.advance(1)  # non-null filler
-    self.charsetnr = struct.unpack('<H', self.read(2))[0]
-    self.length = struct.unpack('<I', self.read(4))[0]
-    self.type_code = byte2int(self.read(1))
-    self.flags = struct.unpack('<H', self.read(2))[0]
-    self.scale = byte2int(self.read(1))  # "decimals"
-    self.advance(2)  # filler (always 0x00)
-
-    # 'default' is a length coded binary and is still in the buffer?
-    # not used for normal result sets...
-
-  def description(self):
-    """Provides a 7-item tuple compatible with the Python PEP249 DB Spec."""
-    desc = []
-    desc.append(self.name)
-    desc.append(self.type_code)
-    desc.append(None) # TODO: display_length; should this be self.length?
-    desc.append(self.get_column_length()) # 'internal_size'
-    desc.append(self.get_column_length()) # 'precision'  # TODO: why!?!?
-    desc.append(self.scale)
-
-    # 'null_ok' -- can this be True/False rather than 1/0?
-    #              if so just do:  desc.append(bool(self.flags % 2 == 0))
-    if self.flags % 2 == 0:
-      desc.append(1)
-    else:
-      desc.append(0)
-    return tuple(desc)
-
-  def get_column_length(self):
-    if self.type_code == FIELD_TYPE.VAR_STRING:
-      mblen = MBLENGTH.get(self.charsetnr, 1)
-      return self.length // mblen
-    return self.length
-
-  def __str__(self):
-    return ('%s %s.%s.%s, type=%s'
-            % (self.__class__, self.db, self.table_name, self.name,
-               self.type_code))
-
-
-class Connection(object):
-    """
-    Representation of a socket with a mysql server.
-
-    The proper way to get an instance of this class is to call
-    connect()."""
-    errorhandler = defaulterrorhandler
-
-    def __init__(self, host="localhost", user=None, passwd="",
-                 db=None, port=3306, unix_socket=None,
-                 charset='', sql_mode=None,
-                 read_default_file=None, conv=decoders, use_unicode=None,
-                 client_flag=0, cursorclass=Cursor, init_command=None,
-                 connect_timeout=None, ssl=None, read_default_group=None,
-                 compress=None, named_pipe=None):
-        """
-        Establish a connection to the MySQL database. Accepts several
-        arguments:
-
-        host: Host where the database server is located
-        user: Username to log in as
-        passwd: Password to use.
-        db: Database to use, None to not use a particular one.
-        port: MySQL port to use, default is usually OK.
-        unix_socket: Optionally, you can use a unix socket rather than TCP/IP.
-        charset: Charset you want to use.
-        sql_mode: Default SQL_MODE to use.
-        read_default_file: Specifies  my.cnf file to read these parameters from under the [client] section.
-        conv: Decoders dictionary to use instead of the default one. This is used to provide custom marshalling of types. See converters.
-        use_unicode: Whether or not to default to unicode strings. This option defaults to true for Py3k.
-        client_flag: Custom flags to send to MySQL. Find potential values in constants.CLIENT.
-        cursorclass: Custom cursor class to use.
-        init_command: Initial SQL statement to run when connection is established.
-        connect_timeout: Timeout before throwing an exception when connecting.
-        ssl: A dict of arguments similar to mysql_ssl_set()'s parameters. For now the capath and cipher arguments are not supported.
-        read_default_group: Group to read from in the configuration file.
-        compress; Not supported
-        named_pipe: Not supported
-        """
-
-        if use_unicode is None and sys.version_info[0] > 2:
-            use_unicode = True
-
-        if compress or named_pipe:
-            raise NotImplementedError, "compress and named_pipe arguments are not supported"
-
-        if ssl and (ssl.has_key('capath') or ssl.has_key('cipher')):
-            raise NotImplementedError, 'ssl options capath and cipher are not supported'
-
-        self.ssl = False
-        if ssl:
-            if not SSL_ENABLED:
-                raise NotImplementedError, "ssl module not found"
-            self.ssl = True
-            client_flag |= SSL
-            for k in ('key', 'cert', 'ca'):
-                v = None
-                if ssl.has_key(k):
-                    v = ssl[k]
-                setattr(self, k, v)
-
-        if read_default_group and not read_default_file:
-            if sys.platform.startswith("win"):
-                read_default_file = "c:\\my.ini"
-            else:
-                read_default_file = "/etc/my.cnf"
-
-        if read_default_file:
-            if not read_default_group:
-                read_default_group = "client"
-
-            cfg = ConfigParser.RawConfigParser()
-            cfg.read(os.path.expanduser(read_default_file))
-
-            def _config(key, default):
-                try:
-                    return cfg.get(read_default_group,key)
-                except:
-                    return default
-
-            user = _config("user",user)
-            passwd = _config("password",passwd)
-            host = _config("host", host)
-            db = _config("db",db)
-            unix_socket = _config("socket",unix_socket)
-            port = _config("port", port)
-            charset = _config("default-character-set", charset)
-
-        self.host = host
-        self.port = port
-        self.user = user
-        self.password = passwd
-        self.db = db
-        self.unix_socket = unix_socket
-        if charset:
-            self.charset = charset
-            self.use_unicode = True
-        else:
-            self.charset = DEFAULT_CHARSET
-            self.use_unicode = False
-
-        if use_unicode is not None:
-            self.use_unicode = use_unicode
-
-        client_flag |= CAPABILITIES
-        client_flag |= MULTI_STATEMENTS
-        if self.db:
-            client_flag |= CONNECT_WITH_DB
-        self.client_flag = client_flag
-
-        self.cursorclass = cursorclass
-        self.connect_timeout = connect_timeout
-
-        self._connect()
-
-        self.messages = []
-        self.set_charset(charset)
-        self.encoders = encoders
-        self.decoders = conv
-
-        self._result = None
-        self._affected_rows = 0
-        self.host_info = "Not connected"
-
-        self.autocommit(False)
-
-        if sql_mode is not None:
-            c = self.cursor()
-            c.execute("SET sql_mode=%s", (sql_mode,))
-
-        self.commit()
-
-        if init_command is not None:
-            c = self.cursor()
-            c.execute(init_command)
-
-            self.commit()
-
-
-    def close(self):
-        ''' Send the quit message and close the socket '''
-        if self.socket is None:
-            raise Error("Already closed")
-        send_data = struct.pack('<i',1) + int2byte(COM_QUIT)
-        self.wfile.write(send_data)
-        self.wfile.close()
-        self.rfile.close()
-        self.socket.close()
-        self.socket = None
-        self.rfile = None
-        self.wfile = None
-
-    def autocommit(self, value):
-        ''' Set whether or not to commit after every execute() '''
-        try:
-            self._execute_command(COM_QUERY, "SET AUTOCOMMIT = %s" % \
-                                      self.escape(value))
-            self.read_packet()
-        except:
-            exc,value,tb = sys.exc_info()
-            self.errorhandler(None, exc, value)
-
-    def commit(self):
-        ''' Commit changes to stable storage '''
-        try:
-            self._execute_command(COM_QUERY, "COMMIT")
-            self.read_packet()
-        except:
-            exc,value,tb = sys.exc_info()
-            self.errorhandler(None, exc, value)
-
-    def rollback(self):
-        ''' Roll back the current transaction '''
-        try:
-            self._execute_command(COM_QUERY, "ROLLBACK")
-            self.read_packet()
-        except:
-            exc,value,tb = sys.exc_info()
-            self.errorhandler(None, exc, value)
-
-    def escape(self, obj):
-        ''' Escape whatever value you pass to it  '''
-        return escape_item(obj, self.charset)
-
-    def literal(self, obj):
-        ''' Alias for escape() '''
-        return escape_item(obj, self.charset)
-
-    def cursor(self, cursor=None):
-        ''' Create a new cursor to execute queries with '''
-        if cursor:
-            return cursor(self)
-        return self.cursorclass(self)
-
-    def __enter__(self):
-        ''' Context manager that returns a Cursor '''
-        return self.cursor()
-
-    def __exit__(self, exc, value, traceback):
-        ''' On successful exit, commit. On exception, rollback. '''
-        if exc:
-            self.rollback()
-        else:
-            self.commit()
-
-    # The following methods are INTERNAL USE ONLY (called from Cursor)
-    def query(self, sql):
-        if DEBUG:
-            print "sending query: %s" % sql
-        self._execute_command(COM_QUERY, sql)
-        self._affected_rows = self._read_query_result()
-        return self._affected_rows
-
-    def next_result(self):
-        self._affected_rows = self._read_query_result()
-        return self._affected_rows
-
-    def affected_rows(self):
-        return self._affected_rows
-
-    def kill(self, thread_id):
-        arg = struct.pack('<I', thread_id)
-        try:
-            self._execute_command(COM_PROCESS_KILL, arg)
-        except:
-            exc,value,tb = sys.exc_info()
-            self.errorhandler(None, exc, value)
-            return
-        pkt = self.read_packet()
-        return pkt.is_ok_packet()
-
-    def ping(self, reconnect=True):
-        ''' Check if the server is alive '''
-        try:
-            self._execute_command(COM_PING, "")
-        except:
-            if reconnect:
-                self._connect()
-                return self.ping(False)
-            else:
-                exc,value,tb = sys.exc_info()
-                self.errorhandler(None, exc, value)
-                return
-
-        pkt = self.read_packet()
-        return pkt.is_ok_packet()
-
-    def set_charset(self, charset):
-        try:
-            if charset:
-                self._execute_command(COM_QUERY, "SET NAMES %s" %
-                                      self.escape(charset))
-                self.read_packet()
-                self.charset = charset
-        except:
-            exc,value,tb = sys.exc_info()
-            self.errorhandler(None, exc, value)
-
-    def _connect(self):
-        try:
-            if self.unix_socket and (self.host == 'localhost' or self.host == '127.0.0.1'):
-                sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
-                t = sock.gettimeout()
-                sock.settimeout(self.connect_timeout)
-                sock.connect(self.unix_socket)
-                sock.settimeout(t)
-                self.host_info = "Localhost via UNIX socket"
-                if DEBUG: print 'connected using unix_socket'
-            else:
-                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-                t = sock.gettimeout()
-                sock.settimeout(self.connect_timeout)
-                sock.connect((self.host, self.port))
-                sock.settimeout(t)
-                self.host_info = "socket %s:%d" % (self.host, self.port)
-                if DEBUG: print 'connected using socket'
-            self.socket = sock
-            self.rfile = self.socket.makefile("rb")
-            self.wfile = self.socket.makefile("wb")
-            self._get_server_information()
-            self._request_authentication()
-        except socket.error, e:
-            raise OperationalError(2003, "Can't connect to MySQL server on %r (%s)" % (self.host, e.args[0]))
-
-    def read_packet(self, packet_type=MysqlPacket):
-      """Read an entire "mysql packet" in its entirety from the network
-      and return a MysqlPacket type that represents the results."""
-
-      packet = packet_type(self)
-      packet.check_error()
-      return packet
-
-    def _read_query_result(self):
-        result = MySQLResult(self)
-        result.read()
-        self._result = result
-        return result.affected_rows
-
-    def insert_id(self):
-        if self._result:
-            return self._result.insert_id
-        else:
-            return 0
-
-    def _send_command(self, command, sql):
-        #send_data = struct.pack('<i', len(sql) + 1) + command + sql
-        # could probably be more efficient, at least it's correct
-        if not self.socket:
-            self.errorhandler(None, InterfaceError, "(0, '')")
-
-        if isinstance(sql, unicode):
-            sql = sql.encode(self.charset)
-
-        prelude = struct.pack('<i', len(sql)+1) + int2byte(command)
-        self.wfile.write(prelude + sql)
-        self.wfile.flush()
-        if DEBUG: dump_packet(prelude + sql)
-
-    def _execute_command(self, command, sql):
-        self._send_command(command, sql)
-        
-    def _request_authentication(self):
-        self._send_authentication()
-
-    def _send_authentication(self):
-        self.client_flag |= CAPABILITIES
-        if self.server_version.startswith('5'):
-            self.client_flag |= MULTI_RESULTS
-
-        if self.user is None:
-            raise ValueError, "Did not specify a username"
-
-        charset_id = charset_by_name(self.charset).id
-        self.user = self.user.encode(self.charset)
-
-        data_init = struct.pack('<i', self.client_flag) + struct.pack("<I", 1) + \
-                     int2byte(charset_id) + int2byte(0)*23
-
-        next_packet = 1
-
-        if self.ssl:
-            data = pack_int24(len(data_init)) + int2byte(next_packet) + data_init
-            next_packet += 1
-
-            if DEBUG: dump_packet(data)
-
-            self.wfile.write(data)
-            self.wfile.flush()
-            self.socket = ssl.wrap_self.socketet(self.socket, keyfile=self.key,
-                                                 certfile=self.cert,
-                                                 ssl_version=ssl.PROTOCOL_TLSv1,
-                                                 cert_reqs=ssl.CERT_REQUIRED,
-                                                 ca_certs=self.ca)
-            self.rfile = self.socket.makefile("rb")
-            self.wfile = self.socket.makefile("wb")
-
-        data = data_init + self.user+int2byte(0) + _scramble(self.password.encode(self.charset), self.salt)
-
-        if self.db:
-            self.db = self.db.encode(self.charset)
-            data += self.db + int2byte(0)
-
-        data = pack_int24(len(data)) + int2byte(next_packet) + data
-        next_packet += 2
-
-        if DEBUG: dump_packet(data)
-
-        self.wfile.write(data)
-        self.wfile.flush()
-
-        auth_packet = MysqlPacket(self)
-        auth_packet.check_error()
-        if DEBUG: auth_packet.dump()
-
-        # if old_passwords is enabled the packet will be 1 byte long and
-        # have the octet 254
-
-        if auth_packet.is_eof_packet():
-            # send legacy handshake
-            #raise NotImplementedError, "old_passwords are not supported. Check to see if mysqld was started with --old-passwords, if old-passwords=1 in a my.cnf file, or if there are some short hashes in your mysql.user table."
-            # TODO: is this the correct charset?
-            data = _scramble_323(self.password.encode(self.charset), self.salt.encode(self.charset)) + int2byte(0)
-            data = pack_int24(len(data)) + int2byte(next_packet) + data
-
-            self.wfile.write(data)
-            self.wfile.flush()
-            auth_packet = MysqlPacket(self)
-            auth_packet.check_error()
-            if DEBUG: auth_packet.dump()
-
-
-    # _mysql support
-    def thread_id(self):
-        return self.server_thread_id[0]
-
-    def character_set_name(self):
-        return self.charset
-
-    def get_host_info(self):
-        return self.host_info
-
-    def get_proto_info(self):
-        return self.protocol_version
-
-    def _get_server_information(self):
-        i = 0
-        packet = MysqlPacket(self)
-        data = packet.get_all_data()
-
-        if DEBUG: dump_packet(data)
-        #packet_len = byte2int(data[i:i+1])
-        #i += 4
-        self.protocol_version = byte2int(data[i:i+1])
-
-        i += 1
-        server_end = data.find(int2byte(0), i)
-        # TODO: is this the correct charset? should it be default_charset?
-        self.server_version = data[i:server_end].decode(self.charset)
-
-        i = server_end + 1
-        self.server_thread_id = struct.unpack('<h', data[i:i+2])
-
-        i += 4
-        self.salt = data[i:i+8]
-
-        i += 9
-        if len(data) >= i + 1:
-            i += 1
-
-        self.server_capabilities = struct.unpack('<h', data[i:i+2])[0]
-
-        i += 1
-        self.server_language = byte2int(data[i:i+1])
-        self.server_charset = charset_by_id(self.server_language).name
-
-        i += 16
-        if len(data) >= i+12-1:
-            rest_salt = data[i:i+12]
-            self.salt += rest_salt
-
-    def get_server_info(self):
-        return self.server_version
-
-    Warning = Warning
-    Error = Error
-    InterfaceError = InterfaceError
-    DatabaseError = DatabaseError
-    DataError = DataError
-    OperationalError = OperationalError
-    IntegrityError = IntegrityError
-    InternalError = InternalError
-    ProgrammingError = ProgrammingError
-    NotSupportedError = NotSupportedError
-
-# TODO: move OK and EOF packet parsing/logic into a proper subclass
-#       of MysqlPacket like has been done with FieldDescriptorPacket.
-class MySQLResult(object):
-
-    def __init__(self, connection):
-        from weakref import proxy
-        self.connection = proxy(connection)
-        self.affected_rows = None
-        self.insert_id = None
-        self.server_status = 0
-        self.warning_count = 0
-        self.message = None
-        self.field_count = 0
-        self.description = None
-        self.rows = None
-        self.has_next = None
-
-    def read(self):
-        self.first_packet = self.connection.read_packet()
-
-        # TODO: use classes for different packet types?
-        if self.first_packet.is_ok_packet():
-            self._read_ok_packet()
-        else:
-            self._read_result_packet()
-
-    def _read_ok_packet(self):
-        self.first_packet.advance(1)  # field_count (always '0')
-        self.affected_rows = self.first_packet.read_length_coded_binary()
-        self.insert_id = self.first_packet.read_length_coded_binary()
-        self.server_status = struct.unpack('<H', self.first_packet.read(2))[0]
-        self.warning_count = struct.unpack('<H', self.first_packet.read(2))[0]
-        self.message = self.first_packet.read_all()
-
-    def _read_result_packet(self):
-        self.field_count = byte2int(self.first_packet.read(1))
-        self._get_descriptions()
-        self._read_rowdata_packet()
-
-    # TODO: implement this as an iteratable so that it is more
-    #       memory efficient and lower-latency to client...
-    def _read_rowdata_packet(self):
-      """Read a rowdata packet for each data row in the result set."""
-      rows = []
-      while True:
-        packet = self.connection.read_packet()
-        if packet.is_eof_packet():
-            self.warning_count = packet.read(2)
-            server_status = struct.unpack('<h', packet.read(2))[0]
-            self.has_next = (server_status
-                             & SERVER_STATUS.SERVER_MORE_RESULTS_EXISTS)
-            break
-
-        row = []
-        for field in self.fields:
-            if field.type_code in self.connection.decoders:
-                converter = self.connection.decoders[field.type_code]
-
-                if DEBUG: print "DEBUG: field=%s, converter=%s" % (field, converter)
-                data = packet.read_length_coded_string()
-                converted = None
-                if data != None:
-                    converted = converter(self.connection, field, data)
-
-            row.append(converted)
-
-        rows.append(tuple(row))
-
-      self.affected_rows = len(rows)
-      self.rows = tuple(rows)
-      if DEBUG: self.rows
-
-    def _get_descriptions(self):
-        """Read a column descriptor packet for each column in the result."""
-        self.fields = []
-        description = []
-        for i in xrange(self.field_count):
-            field = self.connection.read_packet(FieldDescriptorPacket)
-            self.fields.append(field)
-            description.append(field.description())
-
-        eof_packet = self.connection.read_packet()
-        assert eof_packet.is_eof_packet(), 'Protocol error, expecting EOF'
-        self.description = tuple(description)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/constants/CLIENT.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/constants/CLIENT.py b/tools/marvin/marvin/pymysql/constants/CLIENT.py
deleted file mode 100644
index 9d11ea1..0000000
--- a/tools/marvin/marvin/pymysql/constants/CLIENT.py
+++ /dev/null
@@ -1,20 +0,0 @@
-
-LONG_PASSWORD = 1
-FOUND_ROWS = 1 << 1
-LONG_FLAG = 1 << 2
-CONNECT_WITH_DB = 1 << 3
-NO_SCHEMA = 1 << 4
-COMPRESS = 1 << 5
-ODBC = 1 << 6
-LOCAL_FILES = 1 << 7
-IGNORE_SPACE = 1 << 8
-PROTOCOL_41 = 1 << 9
-INTERACTIVE = 1 << 10
-SSL = 1 << 11
-IGNORE_SIGPIPE = 1 << 12
-TRANSACTIONS  = 1 << 13
-SECURE_CONNECTION = 1 << 15
-MULTI_STATEMENTS = 1 << 16
-MULTI_RESULTS = 1 << 17
-CAPABILITIES = LONG_PASSWORD|LONG_FLAG|TRANSACTIONS| \
-    PROTOCOL_41|SECURE_CONNECTION

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/constants/COMMAND.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/constants/COMMAND.py b/tools/marvin/marvin/pymysql/constants/COMMAND.py
deleted file mode 100644
index 4a757da..0000000
--- a/tools/marvin/marvin/pymysql/constants/COMMAND.py
+++ /dev/null
@@ -1,23 +0,0 @@
-
-COM_SLEEP = 0x00
-COM_QUIT = 0x01
-COM_INIT_DB = 0x02
-COM_QUERY = 0x03
-COM_FIELD_LIST = 0x04
-COM_CREATE_DB = 0x05
-COM_DROP_DB = 0x06
-COM_REFRESH = 0x07
-COM_SHUTDOWN = 0x08
-COM_STATISTICS = 0x09
-COM_PROCESS_INFO = 0x0a
-COM_CONNECT = 0x0b
-COM_PROCESS_KILL = 0x0c
-COM_DEBUG = 0x0d
-COM_PING = 0x0e
-COM_TIME = 0x0f
-COM_DELAYED_INSERT = 0x10
-COM_CHANGE_USER = 0x11
-COM_BINLOG_DUMP = 0x12
-COM_TABLE_DUMP = 0x13
-COM_CONNECT_OUT = 0x14
-COM_REGISTER_SLAVE = 0x15

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/constants/ER.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/constants/ER.py b/tools/marvin/marvin/pymysql/constants/ER.py
deleted file mode 100644
index 553983f..0000000
--- a/tools/marvin/marvin/pymysql/constants/ER.py
+++ /dev/null
@@ -1,472 +0,0 @@
-
-ERROR_FIRST = 1000
-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
-UPDATE_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
-SP_WRONG_NAME = 1458
-TABLE_NEEDS_UPGRADE = 1459
-SP_NO_AGGREGATE = 1460
-MAX_PREPARED_STMT_COUNT_REACHED = 1461
-VIEW_RECURSIVE = 1462
-NON_GROUPING_FIELD_USED = 1463
-TABLE_CANT_HANDLE_SPKEYS = 1464
-NO_TRIGGERS_ON_SYSTEM_SCHEMA = 1465
-USERNAME = 1466
-HOSTNAME = 1467
-WRONG_STRING_LENGTH = 1468
-ERROR_LAST = 1468

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/constants/FIELD_TYPE.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/constants/FIELD_TYPE.py b/tools/marvin/marvin/pymysql/constants/FIELD_TYPE.py
deleted file mode 100644
index 3df7ff4..0000000
--- a/tools/marvin/marvin/pymysql/constants/FIELD_TYPE.py
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/constants/FLAG.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/constants/FLAG.py b/tools/marvin/marvin/pymysql/constants/FLAG.py
deleted file mode 100644
index f9ebfad..0000000
--- a/tools/marvin/marvin/pymysql/constants/FLAG.py
+++ /dev/null
@@ -1,15 +0,0 @@
-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
-PART_KEY = 16384
-GROUP = 32767
-UNIQUE = 65536

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/constants/SERVER_STATUS.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/constants/SERVER_STATUS.py b/tools/marvin/marvin/pymysql/constants/SERVER_STATUS.py
deleted file mode 100644
index 010f542..0000000
--- a/tools/marvin/marvin/pymysql/constants/SERVER_STATUS.py
+++ /dev/null
@@ -1,12 +0,0 @@
-
-SERVER_STATUS_IN_TRANS = 1
-SERVER_STATUS_AUTOCOMMIT = 2
-SERVER_MORE_RESULTS_EXISTS = 8
-SERVER_QUERY_NO_GOOD_INDEX_USED = 16
-SERVER_QUERY_NO_INDEX_USED = 32
-SERVER_STATUS_CURSOR_EXISTS = 64
-SERVER_STATUS_LAST_ROW_SENT = 128
-SERVER_STATUS_DB_DROPPED = 256
-SERVER_STATUS_NO_BACKSLASH_ESCAPES = 512
-SERVER_STATUS_METADATA_CHANGED = 1024
-

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/constants/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/constants/__init__.py b/tools/marvin/marvin/pymysql/constants/__init__.py
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/converters.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/converters.py b/tools/marvin/marvin/pymysql/converters.py
deleted file mode 100644
index e00f374..0000000
--- a/tools/marvin/marvin/pymysql/converters.py
+++ /dev/null
@@ -1,348 +0,0 @@
-import re
-import datetime
-import time
-import sys
-
-from constants import FIELD_TYPE, FLAG
-from charset import charset_by_id
-
-PYTHON3 = sys.version_info[0] > 2
-
-try:
-    set
-except NameError:
-    try:
-        from sets import BaseSet as set
-    except ImportError:
-        from sets import Set as set
-
-ESCAPE_REGEX = re.compile(r"[\0\n\r\032\'\"\\]")
-ESCAPE_MAP = {'\0': '\\0', '\n': '\\n', '\r': '\\r', '\032': '\\Z',
-              '\'': '\\\'', '"': '\\"', '\\': '\\\\'}
-
-def escape_item(val, charset):
-    if type(val) in [tuple, list, set]:
-        return escape_sequence(val, charset)
-    if type(val) is dict:
-        return escape_dict(val, charset)
-    if PYTHON3 and hasattr(val, "decode") and not isinstance(val, unicode):
-        # deal with py3k bytes
-        val = val.decode(charset)
-    encoder = encoders[type(val)]
-    val = encoder(val)
-    if type(val) is str:
-        return val
-    val = val.encode(charset)
-    return val
-
-def escape_dict(val, charset):
-    n = {}
-    for k, v in val.items():
-        quoted = escape_item(v, charset)
-        n[k] = quoted
-    return n
-
-def escape_sequence(val, charset):
-    n = []
-    for item in val:
-        quoted = escape_item(item, charset)
-        n.append(quoted)
-    return "(" + ",".join(n) + ")"
-
-def escape_set(val, charset):
-    val = map(lambda x: escape_item(x, charset), val)
-    return ','.join(val)
-
-def escape_bool(value):
-    return str(int(value))
-
-def escape_object(value):
-    return str(value)
-
-escape_int = escape_long = escape_object
-
-def escape_float(value):
-    return ('%.15g' % value)
-
-def escape_string(value):
-    return ("'%s'" % ESCAPE_REGEX.sub(
-            lambda match: ESCAPE_MAP.get(match.group(0)), value))
-
-def escape_unicode(value):
-    return escape_string(value)
-
-def escape_None(value):
-    return 'NULL'
-
-def escape_timedelta(obj):
-    seconds = int(obj.seconds) % 60
-    minutes = int(obj.seconds // 60) % 60
-    hours = int(obj.seconds // 3600) % 24 + int(obj.days) * 24
-    return escape_string('%02d:%02d:%02d' % (hours, minutes, seconds))
-
-def escape_time(obj):
-    s = "%02d:%02d:%02d" % (int(obj.hour), int(obj.minute),
-                            int(obj.second))
-    if obj.microsecond:
-        s += ".%f" % obj.microsecond
-
-    return escape_string(s)
-
-def escape_datetime(obj):
-    return escape_string(obj.strftime("%Y-%m-%d %H:%M:%S"))
-
-def escape_date(obj):
-    return escape_string(obj.strftime("%Y-%m-%d"))
-
-def escape_struct_time(obj):
-    return escape_datetime(datetime.datetime(*obj[:6]))
-
-def convert_datetime(connection, field, obj):
-    """Returns a DATETIME or TIMESTAMP column value as a datetime object:
-
-      >>> datetime_or_None('2007-02-25 23:06:20')
-      datetime.datetime(2007, 2, 25, 23, 6, 20)
-      >>> datetime_or_None('2007-02-25T23:06:20')
-      datetime.datetime(2007, 2, 25, 23, 6, 20)
-
-    Illegal values are returned as None:
-
-      >>> datetime_or_None('2007-02-31T23:06:20') is None
-      True
-      >>> datetime_or_None('0000-00-00 00:00:00') is None
-      True
-
-    """
-    if not isinstance(obj, unicode):
-        obj = obj.decode(connection.charset)
-    if ' ' in obj:
-        sep = ' '
-    elif 'T' in obj:
-        sep = 'T'
-    else:
-        return convert_date(connection, field, obj)
-
-    try:
-        ymd, hms = obj.split(sep, 1)
-        return datetime.datetime(*[ int(x) for x in ymd.split('-')+hms.split(':') ])
-    except ValueError:
-        return convert_date(connection, field, obj)
-
-def convert_timedelta(connection, field, obj):
-    """Returns a TIME column as a timedelta object:
-
-      >>> timedelta_or_None('25:06:17')
-      datetime.timedelta(1, 3977)
-      >>> timedelta_or_None('-25:06:17')
-      datetime.timedelta(-2, 83177)
-
-    Illegal values are returned as None:
-
-      >>> timedelta_or_None('random crap') is None
-      True
-
-    Note that MySQL always returns TIME columns as (+|-)HH:MM:SS, but
-    can accept values as (+|-)DD HH:MM:SS. The latter format will not
-    be parsed correctly by this function.
-    """
-    from math import modf
-    try:
-        if not isinstance(obj, unicode):
-            obj = obj.decode(connection.charset)
-        hours, minutes, seconds = tuple([int(x) for x in obj.split(':')])
-        tdelta = datetime.timedelta(
-            hours = int(hours),
-            minutes = int(minutes),
-            seconds = int(seconds),
-            microseconds = int(modf(float(seconds))[0]*1000000),
-            )
-        return tdelta
-    except ValueError:
-        return None
-
-def convert_time(connection, field, obj):
-    """Returns a TIME column as a time object:
-
-      >>> time_or_None('15:06:17')
-      datetime.time(15, 6, 17)
-
-    Illegal values are returned as None:
-
-      >>> time_or_None('-25:06:17') is None
-      True
-      >>> time_or_None('random crap') is None
-      True
-
-    Note that MySQL always returns TIME columns as (+|-)HH:MM:SS, but
-    can accept values as (+|-)DD HH:MM:SS. The latter format will not
-    be parsed correctly by this function.
-
-    Also note that MySQL's TIME column corresponds more closely to
-    Python's timedelta and not time. However if you want TIME columns
-    to be treated as time-of-day and not a time offset, then you can
-    use set this function as the converter for FIELD_TYPE.TIME.
-    """
-    from math import modf
-    try:
-        hour, minute, second = obj.split(':')
-        return datetime.time(hour=int(hour), minute=int(minute),
-                             second=int(second),
-                             microsecond=int(modf(float(second))[0]*1000000))
-    except ValueError:
-        return None
-
-def convert_date(connection, field, obj):
-    """Returns a DATE column as a date object:
-
-      >>> date_or_None('2007-02-26')
-      datetime.date(2007, 2, 26)
-
-    Illegal values are returned as None:
-
-      >>> date_or_None('2007-02-31') is None
-      True
-      >>> date_or_None('0000-00-00') is None
-      True
-
-    """
-    try:
-        if not isinstance(obj, unicode):
-            obj = obj.decode(connection.charset)
-        return datetime.date(*[ int(x) for x in obj.split('-', 2) ])
-    except ValueError:
-        return None
-
-def convert_mysql_timestamp(connection, field, timestamp):
-    """Convert a MySQL TIMESTAMP to a Timestamp object.
-
-    MySQL >= 4.1 returns TIMESTAMP in the same format as DATETIME:
-
-      >>> mysql_timestamp_converter('2007-02-25 22:32:17')
-      datetime.datetime(2007, 2, 25, 22, 32, 17)
-
-    MySQL < 4.1 uses a big string of numbers:
-
-      >>> mysql_timestamp_converter('20070225223217')
-      datetime.datetime(2007, 2, 25, 22, 32, 17)
-
-    Illegal values are returned as None:
-
-      >>> mysql_timestamp_converter('2007-02-31 22:32:17') is None
-      True
-      >>> mysql_timestamp_converter('00000000000000') is None
-      True
-
-    """
-    if not isinstance(timestamp, unicode):
-        timestamp = timestamp.decode(connection.charset)
-
-    if timestamp[4] == '-':
-        return convert_datetime(connection, field, timestamp)
-    timestamp += "0"*(14-len(timestamp)) # padding
-    year, month, day, hour, minute, second = \
-        int(timestamp[:4]), int(timestamp[4:6]), int(timestamp[6:8]), \
-        int(timestamp[8:10]), int(timestamp[10:12]), int(timestamp[12:14])
-    try:
-        return datetime.datetime(year, month, day, hour, minute, second)
-    except ValueError:
-        return None
-
-def convert_set(s):
-    return set(s.split(","))
-
-def convert_bit(connection, field, b):
-    #b = "\x00" * (8 - len(b)) + b # pad w/ zeroes
-    #return struct.unpack(">Q", b)[0]
-    #
-    # the snippet above is right, but MySQLdb doesn't process bits,
-    # so we shouldn't either
-    return b
-
-def convert_characters(connection, field, data):
-    field_charset = charset_by_id(field.charsetnr).name
-    if field.flags & FLAG.SET:
-        return convert_set(data.decode(field_charset))
-    if field.flags & FLAG.BINARY:
-        return data
-
-    if connection.use_unicode:
-        data = data.decode(field_charset)
-    elif connection.charset != field_charset:
-        data = data.decode(field_charset)
-        data = data.encode(connection.charset)
-    return data
-
-def convert_int(connection, field, data):
-    return int(data)
-
-def convert_long(connection, field, data):
-    return long(data)
-
-def convert_float(connection, field, data):
-    return float(data)
-
-encoders = {
-        bool: escape_bool,
-        int: escape_int,
-        long: escape_long,
-        float: escape_float,
-        str: escape_string,
-        unicode: escape_unicode,
-        tuple: escape_sequence,
-        list:escape_sequence,
-        set:escape_sequence,
-        dict:escape_dict,
-        type(None):escape_None,
-        datetime.date: escape_date,
-        datetime.datetime : escape_datetime,
-        datetime.timedelta : escape_timedelta,
-        datetime.time : escape_time,
-        time.struct_time : escape_struct_time,
-        }
-
-decoders = {
-        FIELD_TYPE.BIT: convert_bit,
-        FIELD_TYPE.TINY: convert_int,
-        FIELD_TYPE.SHORT: convert_int,
-        FIELD_TYPE.LONG: convert_long,
-        FIELD_TYPE.FLOAT: convert_float,
-        FIELD_TYPE.DOUBLE: convert_float,
-        FIELD_TYPE.DECIMAL: convert_float,
-        FIELD_TYPE.NEWDECIMAL: convert_float,
-        FIELD_TYPE.LONGLONG: convert_long,
-        FIELD_TYPE.INT24: convert_int,
-        FIELD_TYPE.YEAR: convert_int,
-        FIELD_TYPE.TIMESTAMP: convert_mysql_timestamp,
-        FIELD_TYPE.DATETIME: convert_datetime,
-        FIELD_TYPE.TIME: convert_timedelta,
-        FIELD_TYPE.DATE: convert_date,
-        FIELD_TYPE.SET: convert_set,
-        FIELD_TYPE.BLOB: convert_characters,
-        FIELD_TYPE.TINY_BLOB: convert_characters,
-        FIELD_TYPE.MEDIUM_BLOB: convert_characters,
-        FIELD_TYPE.LONG_BLOB: convert_characters,
-        FIELD_TYPE.STRING: convert_characters,
-        FIELD_TYPE.VAR_STRING: convert_characters,
-        FIELD_TYPE.VARCHAR: convert_characters,
-        #FIELD_TYPE.BLOB: str,
-        #FIELD_TYPE.STRING: str,
-        #FIELD_TYPE.VAR_STRING: str,
-        #FIELD_TYPE.VARCHAR: str
-        }
-conversions = decoders  # for MySQLdb compatibility
-
-try:
-    # python version > 2.3
-    from decimal import Decimal
-    def convert_decimal(connection, field, data):
-        data = data.decode(connection.charset)
-        return Decimal(data)
-    decoders[FIELD_TYPE.DECIMAL] = convert_decimal
-    decoders[FIELD_TYPE.NEWDECIMAL] = convert_decimal
-
-    def escape_decimal(obj):
-        return unicode(obj)
-    encoders[Decimal] = escape_decimal
-
-except ImportError:
-    pass

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60cd6538/tools/marvin/marvin/pymysql/cursors.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/pymysql/cursors.py b/tools/marvin/marvin/pymysql/cursors.py
deleted file mode 100644
index 4e10f83..0000000
--- a/tools/marvin/marvin/pymysql/cursors.py
+++ /dev/null
@@ -1,297 +0,0 @@
-# -*- coding: utf-8 -*-
-import struct
-import re
-
-try:
-    import cStringIO as StringIO
-except ImportError:
-    import StringIO
-
-from err import Warning, Error, InterfaceError, DataError, \
-             DatabaseError, OperationalError, IntegrityError, InternalError, \
-            NotSupportedError, ProgrammingError
-
-insert_values = re.compile(r'\svalues\s*(\(.+\))', re.IGNORECASE)
-
-class Cursor(object):
-    '''
-    This is the object you use to interact with the database.
-    '''
-    def __init__(self, connection):
-        '''
-        Do not create an instance of a Cursor yourself. Call
-        connections.Connection.cursor().
-        '''
-        from weakref import proxy
-        self.connection = proxy(connection)
-        self.description = None
-        self.rownumber = 0
-        self.rowcount = -1
-        self.arraysize = 1
-        self._executed = None
-        self.messages = []
-        self.errorhandler = connection.errorhandler
-        self._has_next = None
-        self._rows = ()
-
-    def __del__(self):
-        '''
-        When this gets GC'd close it.
-        '''
-        self.close()
-
-    def close(self):
-        '''
-        Closing a cursor just exhausts all remaining data.
-        '''
-        if not self.connection:
-            return
-        try:
-            while self.nextset():
-                pass
-        except:
-            pass
-
-        self.connection = None
-
-    def _get_db(self):
-        if not self.connection:
-            self.errorhandler(self, ProgrammingError, "cursor closed")
-        return self.connection
-
-    def _check_executed(self):
-        if not self._executed:
-            self.errorhandler(self, ProgrammingError, "execute() first")
-
-    def setinputsizes(self, *args):
-        """Does nothing, required by DB API."""
-
-    def setoutputsizes(self, *args):
-        """Does nothing, required by DB API."""
-
-    def nextset(self):
-        ''' Get the next query set '''
-        if self._executed:
-            self.fetchall()
-        del self.messages[:]
-
-        if not self._has_next:
-            return None
-        connection = self._get_db()
-        connection.next_result()
-        self._do_get_result()
-        return True
-
-    def execute(self, query, args=None):
-        ''' Execute a query '''
-        from sys import exc_info
-
-        conn = self._get_db()
-        charset = conn.charset
-        del self.messages[:]
-
-        # TODO: make sure that conn.escape is correct
-
-        if args is not None:
-            if isinstance(args, tuple) or isinstance(args, list):
-                escaped_args = tuple(conn.escape(arg) for arg in args)
-            elif isinstance(args, dict):
-                escaped_args = dict((key, conn.escape(val)) for (key, val) in args.items())
-            else:
-                #If it's not a dictionary let's try escaping it anyways.
-                #Worst case it will throw a Value error
-                escaped_args = conn.escape(args)
-
-            query = query % escaped_args
-
-        if isinstance(query, unicode):
-            query = query.encode(charset)
-
-        result = 0
-        try:
-            result = self._query(query)
-        except:
-            exc, value, tb = exc_info()
-            del tb
-            self.messages.append((exc,value))
-            self.errorhandler(self, exc, value)
-
-        self._executed = query
-        return result
-
-    def executemany(self, query, args):
-        ''' Run several data against one query '''
-        del self.messages[:]
-        #conn = self._get_db()
-        if not args:
-            return
-        #charset = conn.charset
-        #if isinstance(query, unicode):
-        #    query = query.encode(charset)
-
-        self.rowcount = sum([ self.execute(query, arg) for arg in args ])
-        return self.rowcount
-
-
-    def callproc(self, procname, args=()):
-        """Execute stored procedure procname with args
-
-        procname -- string, name of procedure to execute on server
-
-        args -- Sequence of parameters to use with procedure
-
-        Returns the original args.
-
-        Compatibility warning: PEP-249 specifies that any modified
-        parameters must be returned. This is currently impossible
-        as they are only available by storing them in a server
-        variable and then retrieved by a query. Since stored
-        procedures return zero or more result sets, there is no
-        reliable way to get at OUT or INOUT parameters via callproc.
-        The server variables are named @_procname_n, where procname
-        is the parameter above and n is the position of the parameter
-        (from zero). Once all result sets generated by the procedure
-        have been fetched, you can issue a SELECT @_procname_0, ...
-        query using .execute() to get any OUT or INOUT values.
-
-        Compatibility warning: The act of calling a stored procedure
-        itself creates an empty result set. This appears after any
-        result sets generated by the procedure. This is non-standard
-        behavior with respect to the DB-API. Be sure to use nextset()
-        to advance through all result sets; otherwise you may get
-        disconnected.
-        """
-        conn = self._get_db()
-        for index, arg in enumerate(args):
-            q = "SET @_%s_%d=%s" % (procname, index, conn.escape(arg))
-            if isinstance(q, unicode):
-                q = q.encode(conn.charset)
-            self._query(q)
-            self.nextset()
-
-        q = "CALL %s(%s)" % (procname,
-                             ','.join(['@_%s_%d' % (procname, i)
-                                       for i in range(len(args))]))
-        if isinstance(q, unicode):
-            q = q.encode(conn.charset)
-        self._query(q)
-        self._executed = q
-
-        return args
-
-    def fetchone(self):
-        ''' Fetch the next row '''
-        self._check_executed()
-        if self._rows is None or self.rownumber >= len(self._rows):
-            return None
-        result = self._rows[self.rownumber]
-        self.rownumber += 1
-        return result
-
-    def fetchmany(self, size=None):
-        ''' Fetch several rows '''
-        self._check_executed()
-        end = self.rownumber + (size or self.arraysize)
-        result = self._rows[self.rownumber:end]
-        if self._rows is None:
-            return None
-        self.rownumber = min(end, len(self._rows))
-        return result
-
-    def fetchall(self):
-        ''' Fetch all the rows '''
-        self._check_executed()
-        if self._rows is None:
-            return None
-        if self.rownumber:
-            result = self._rows[self.rownumber:]
-        else:
-            result = self._rows
-        self.rownumber = len(self._rows)
-        return result
-
-    def scroll(self, value, mode='relative'):
-        self._check_executed()
-        if mode == 'relative':
-            r = self.rownumber + value
-        elif mode == 'absolute':
-            r = value
-        else:
-            self.errorhandler(self, ProgrammingError,
-                    "unknown scroll mode %s" % mode)
-
-        if r < 0 or r >= len(self._rows):
-            self.errorhandler(self, IndexError, "out of range")
-        self.rownumber = r
-
-    def _query(self, q):
-        conn = self._get_db()
-        self._last_executed = q
-        conn.query(q)
-        self._do_get_result()
-        return self.rowcount
-
-    def _do_get_result(self):
-        conn = self._get_db()
-        self.rowcount = conn._result.affected_rows
-
-        self.rownumber = 0
-        self.description = conn._result.description
-        self.lastrowid = conn._result.insert_id
-        self._rows = conn._result.rows
-        self._has_next = conn._result.has_next
-
-    def __iter__(self):
-        return iter(self.fetchone, None)
-
-    Warning = Warning
-    Error = Error
-    InterfaceError = InterfaceError
-    DatabaseError = DatabaseError
-    DataError = DataError
-    OperationalError = OperationalError
-    IntegrityError = IntegrityError
-    InternalError = InternalError
-    ProgrammingError = ProgrammingError
-    NotSupportedError = NotSupportedError
-
-class DictCursor(Cursor):
-    """A cursor which returns results as a dictionary"""
-
-    def execute(self, query, args=None):
-        result = super(DictCursor, self).execute(query, args)
-        if self.description:
-            self._fields = [ field[0] for field in self.description ]
-        return result
-
-    def fetchone(self):
-        ''' Fetch the next row '''
-        self._check_executed()
-        if self._rows is None or self.rownumber >= len(self._rows):
-            return None
-        result = dict(zip(self._fields, self._rows[self.rownumber]))
-        self.rownumber += 1
-        return result
-
-    def fetchmany(self, size=None):
-        ''' Fetch several rows '''
-        self._check_executed()
-        if self._rows is None:
-            return None
-        end = self.rownumber + (size or self.arraysize)
-        result = [ dict(zip(self._fields, r)) for r in self._rows[self.rownumber:end] ]
-        self.rownumber = min(end, len(self._rows))
-        return tuple(result)
-
-    def fetchall(self):
-        ''' Fetch all the rows '''
-        self._check_executed()
-        if self._rows is None:
-            return None
-        if self.rownumber:
-            result = [ dict(zip(self._fields, r)) for r in self._rows[self.rownumber:] ]
-        else:
-            result = [ dict(zip(self._fields, r)) for r in self._rows ]
-        self.rownumber = len(self._rows)
-        return tuple(result)
-


Mime
View raw message