From 797d9c3029c0660a43b71130cac093343e15f0dc Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Sat, 5 Jan 2013 09:34:59 +0900 Subject: [PATCH 01/20] Support `autocommit=True` for constructor argument. --- MySQLdb/connections.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index 6bc1613..aeac731 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -139,6 +139,9 @@ class Connection(_mysql.connection): local_infile integer, non-zero enables LOAD LOCAL INFILE; zero disables + autocommit + If True, autocommit is enabled. + There are a number of undocumented, non-standard methods. See the documentation for the MySQL C API for some hints on what they do. @@ -224,7 +227,7 @@ class Connection(_mysql.connection): self.encoders[types.StringType] = string_literal self.encoders[types.UnicodeType] = unicode_literal self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS - if self._transactional: + if self._transactional and not kwargs2.pop('autocommit', False): # PEP-249 requires autocommit to be initially off self.autocommit(False) self.messages = [] From c1b8e8a0474c44f60ed8e08b3be8dc7f293ce7b8 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Tue, 21 May 2013 12:09:55 +0900 Subject: [PATCH 02/20] autocommit=None means using server default. --- MySQLdb/connections.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index aeac731..2b423e7 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -140,7 +140,9 @@ class Connection(_mysql.connection): integer, non-zero enables LOAD LOCAL INFILE; zero disables autocommit + If False (default), autocommit is disabled. If True, autocommit is enabled. + If None, autocommit isn't set and server default is used. There are a number of undocumented, non-standard methods. See the documentation for the MySQL C API for some hints on what they do. @@ -227,9 +229,11 @@ class Connection(_mysql.connection): self.encoders[types.StringType] = string_literal self.encoders[types.UnicodeType] = unicode_literal self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS - if self._transactional and not kwargs2.pop('autocommit', False): + if self._transactional: # PEP-249 requires autocommit to be initially off - self.autocommit(False) + autocommit = kwargs2.pop('autocommit', False) + if autocommit is not None: + self.autocommit(bool(True)) self.messages = [] def cursor(self, cursorclass=None): From 470eb56c4ddb742c70d9e11c4f6601ccf4071fe5 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Tue, 21 May 2013 13:32:23 +0900 Subject: [PATCH 03/20] Fix typo. --- MySQLdb/connections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index 2b423e7..908d72a 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -233,7 +233,7 @@ class Connection(_mysql.connection): # PEP-249 requires autocommit to be initially off autocommit = kwargs2.pop('autocommit', False) if autocommit is not None: - self.autocommit(bool(True)) + self.autocommit(bool(autocommit)) self.messages = [] def cursor(self, cursorclass=None): From f064692a36c49713463fccb5befa1e13a9beb8d4 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Wed, 22 May 2013 22:33:20 +0900 Subject: [PATCH 04/20] 'BEGIN' on __enter__ if autocommit is enabled. --- MySQLdb/connections.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index 908d72a..40a6150 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -187,6 +187,9 @@ class Connection(_mysql.connection): kwargs2['client_flag'] = client_flag + # PEP-249 requires autocommit to be initially off + autocommit = kwargs2.pop('autocommit', False) + super(Connection, self).__init__(*args, **kwargs2) self.cursorclass = cursorclass self.encoders = dict([ (k, v) for k, v in conv.items() @@ -229,13 +232,29 @@ class Connection(_mysql.connection): self.encoders[types.StringType] = string_literal self.encoders[types.UnicodeType] = unicode_literal self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS + self._autocommit = None if self._transactional: - # PEP-249 requires autocommit to be initially off - autocommit = kwargs2.pop('autocommit', False) if autocommit is not None: - self.autocommit(bool(autocommit)) + self.autocommit(autocommit) self.messages = [] + def autocommit(self, on): + on = bool(on) + _mysql.connection.autocommit(self, on) + self._autocommit = on + + def get_autocommit(self): + if self._autocommit is None: + self._update_autocommit() + return self._autocommit + + def _update_autocommit(self): + cursor = cursors.Cursor(self) + cursor.execute("SELECT @@AUTOCOMMIT") + row = cursor.fetchone() + self._autocommit = bool(row[0]) + cursor.close() + def cursor(self, cursorclass=None): """ @@ -248,6 +267,8 @@ class Connection(_mysql.connection): return (cursorclass or self.cursorclass)(self) def __enter__(self): + if self.get_autocommit(): + self.query("BEGIN") return self.cursor() def __exit__(self, exc, value, tb): From a050932372d7b94e8606caa0f242dd2ff4b77cfe Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 14 Jun 2013 13:34:07 -0400 Subject: [PATCH 05/20] If setuptools is importable, don't force use of 'distribute'. Allows use of post-merge setuptools 0.7. --- setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 798f96f..e2dee0f 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,11 @@ import os import sys -from distribute_setup import use_setuptools -use_setuptools() +try: + import setuptools +except ImportError: + from distribute_setup import use_setuptools + use_setuptools() from setuptools import setup, Extension if not hasattr(sys, "hexversion") or sys.hexversion < 0x02040000: From 0226f1a727441746bbe2bc396de5eccea7f395f8 Mon Sep 17 00:00:00 2001 From: Dima Tyzhnenko Date: Mon, 15 Jul 2013 18:11:07 +0300 Subject: [PATCH 06/20] Fix problem with return None if Datetime field contained microsecond (Issue #24) --- MySQLdb/times.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/MySQLdb/times.py b/MySQLdb/times.py index bc92eb4..f3a92d7 100644 --- a/MySQLdb/times.py +++ b/MySQLdb/times.py @@ -60,9 +60,13 @@ def DateTime_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 '.' in s: + s, ms = s.split('.') + else: + ms = 0 + h, m, s, ms = int(h), int(m), int(s), int(ms) + td = timedelta(hours=abs(h), minutes=m, seconds=s, + microseconds=ms) if h < 0: return -td else: @@ -74,9 +78,13 @@ def TimeDelta_or_None(s): 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)) + if '.' in s: + s, ms = s.split('.') + else: + ms = 0 + h, m, s, ms = int(h), int(m), int(s), int(ms) + return time(hour=h, minute=m, second=s, + microsecond=ms) except ValueError: return None From 7e73533dd96da3fcd4c9eb3e9cff4a4dee19d8f0 Mon Sep 17 00:00:00 2001 From: Chip Turner Date: Fri, 23 Aug 2013 13:08:07 -0700 Subject: [PATCH 07/20] Extend read_timeout support to also include write_timeouts --- _mysql.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/_mysql.c b/_mysql.c index c0ffddb..6ebbb4e 100644 --- a/_mysql.c +++ b/_mysql.c @@ -121,7 +121,7 @@ static int _mysql_server_init_done = 0; /* According to https://dev.mysql.com/doc/refman/5.1/en/mysql-options.html The MYSQL_OPT_READ_TIMEOUT apear in the version 5.1.12 */ #if MYSQL_VERSION_ID > 50112 -#define HAVE_MYSQL_OPT_READ_TIMEOUT 1 +#define HAVE_MYSQL_OPT_TIMEOUTS 1 #endif PyObject * @@ -566,13 +566,15 @@ _mysql_ConnectionObject_Initialize( "read_default_file", "read_default_group", "client_flag", "ssl", "local_infile", -#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT +#ifdef HAVE_MYSQL_OPT_TIMEOUTS "read_timeout", + "write_timeout", #endif NULL } ; int connect_timeout = 0; -#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT +#ifdef HAVE_MYSQL_OPT_TIMEOUTS int read_timeout = 0; + int write_timeout = 0; #endif int compress = -1, named_pipe = -1, local_infile = -1; char *init_command=NULL, @@ -584,8 +586,8 @@ _mysql_ConnectionObject_Initialize( check_server_init(-1); if (!PyArg_ParseTupleAndKeywords(args, kwargs, -#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT - "|ssssisOiiisssiOii:connect", +#ifdef HAVE_MYSQL_OPT_TIMEOUTS + "|ssssisOiiisssiOiii:connect", #else "|ssssisOiiisssiOi:connect", #endif @@ -598,8 +600,9 @@ _mysql_ConnectionObject_Initialize( &read_default_group, &client_flag, &ssl, &local_infile -#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT +#ifdef HAVE_MYSQL_OPT_TIMEOUTS , &read_timeout + , &write_timeout #endif )) return -1; @@ -636,12 +639,17 @@ _mysql_ConnectionObject_Initialize( mysql_options(&(self->connection), MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout); } -#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT +#ifdef HAVE_MYSQL_OPT_TIMEOUTS if (read_timeout) { unsigned int timeout = read_timeout; mysql_options(&(self->connection), MYSQL_OPT_READ_TIMEOUT, (char *)&timeout); } + if (write_timeout) { + unsigned int timeout = write_timeout; + mysql_options(&(self->connection), MYSQL_OPT_WRITE_TIMEOUT, + (char *)&timeout); + } #endif if (compress != -1) { mysql_options(&(self->connection), MYSQL_OPT_COMPRESS, 0); From e20b631d167c293e976d95c8c1bf496d717c8952 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Mon, 30 Sep 2013 09:27:48 -0700 Subject: [PATCH 08/20] Add support for tox --- .gitignore | 1 + tox.ini | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 77d358c..968f0e6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,6 @@ *.zip *.egg *.egg-info/ +.tox/ build/ dist/ diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..350e3f7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,10 @@ +[tox] +envlist = py25, py26, py27, py33 + +[testenv] +setenv = + TESTDB=travis.cnf +commands = + nosetests {posargs:-w tests -v} +deps = + nose From 53ebb0fced409379e838fbc65ed639e96b1b3af4 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Mon, 30 Sep 2013 13:51:30 -0700 Subject: [PATCH 09/20] Change one assertTrue to assertEquals to get better failure output --- tests/test_MySQLdb_capabilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_MySQLdb_capabilities.py b/tests/test_MySQLdb_capabilities.py index ebec1e6..ead6982 100644 --- a/tests/test_MySQLdb_capabilities.py +++ b/tests/test_MySQLdb_capabilities.py @@ -77,7 +77,7 @@ class test_MySQLdb(capabilities.DatabaseTest): try: self.cursor.execute("describe some_non_existent_table"); except self.connection.ProgrammingError, msg: - self.assertTrue(msg[0] == ER.NO_SUCH_TABLE) + self.assertEquals(msg[0], ER.NO_SUCH_TABLE) def test_bug_3514287(self): c = self.cursor From a1dd63614f6becbacabf0016f6293bf7f720c3f4 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Mon, 30 Sep 2013 16:24:18 -0700 Subject: [PATCH 10/20] tox.ini: Add ipdb as a dep because it's very useful for debugging --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 350e3f7..e7bb971 100644 --- a/tox.ini +++ b/tox.ini @@ -7,4 +7,5 @@ setenv = commands = nosetests {posargs:-w tests -v} deps = + ipdb nose From 3dbf035fa5866364a53e17b79172746fe7e9b11e Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Wed, 2 Oct 2013 02:10:02 +0900 Subject: [PATCH 11/20] More precise get_autocommit based on server_status. --- MySQLdb/connections.py | 15 ++------------- _mysql.c | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index 40a6150..0c529f7 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -240,21 +240,10 @@ class Connection(_mysql.connection): def autocommit(self, on): on = bool(on) - _mysql.connection.autocommit(self, on) + if self.get_autocommit() != on: + _mysql.connection.autocommit(self, on) self._autocommit = on - def get_autocommit(self): - if self._autocommit is None: - self._update_autocommit() - return self._autocommit - - def _update_autocommit(self): - cursor = cursors.Cursor(self) - cursor.execute("SELECT @@AUTOCOMMIT") - row = cursor.fetchone() - self._autocommit = bool(row[0]) - cursor.close() - def cursor(self, cursorclass=None): """ diff --git a/_mysql.c b/_mysql.c index c0ffddb..0fd7442 100644 --- a/_mysql.c +++ b/_mysql.c @@ -891,7 +891,21 @@ _mysql_ConnectionObject_autocommit( if (err) return _mysql_Exception(self); Py_INCREF(Py_None); return Py_None; -} +} + +static char _mysql_ConnectionObject_get_autocommit__doc__[] = +"Get the autocommit mode. True when enable; False when disable.\n"; + +static PyObject * +_mysql_ConnectionObject_get_autocommit( + _mysql_ConnectionObject *self, + PyObject *args) +{ + if (self->connection.server_status & SERVER_STATUS_AUTOCOMMIT) { + Py_RETURN_TRUE; + } + Py_RETURN_FALSE; +} static char _mysql_ConnectionObject_commit__doc__[] = "Commits the current transaction\n\ @@ -2317,6 +2331,12 @@ static PyMethodDef _mysql_ConnectionObject_methods[] = { METH_VARARGS, _mysql_ConnectionObject_autocommit__doc__ }, + { + "get_autocommit", + (PyCFunction)_mysql_ConnectionObject_get_autocommit, + METH_NOARGS, + _mysql_ConnectionObject_get_autocommit__doc__ + }, { "commit", (PyCFunction)_mysql_ConnectionObject_commit, From 2204283605e8c450223965eda8d8f357d5fe4c90 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Wed, 2 Oct 2013 02:17:48 +0900 Subject: [PATCH 12/20] Remove unused variable. --- MySQLdb/connections.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index 0c529f7..908706a 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -232,7 +232,6 @@ class Connection(_mysql.connection): self.encoders[types.StringType] = string_literal self.encoders[types.UnicodeType] = unicode_literal self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS - self._autocommit = None if self._transactional: if autocommit is not None: self.autocommit(autocommit) @@ -242,7 +241,6 @@ class Connection(_mysql.connection): on = bool(on) if self.get_autocommit() != on: _mysql.connection.autocommit(self, on) - self._autocommit = on def cursor(self, cursorclass=None): """ From 052955e093e8db7b1a2fdfd7707de39980f849cd Mon Sep 17 00:00:00 2001 From: Dima Tyzhnenko Date: Mon, 7 Oct 2013 12:34:14 +0300 Subject: [PATCH 13/20] Fix cut off SQL query when its contained `))`, edit insert_values regexp. Fixes issue #33. --- MySQLdb/cursors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py index 7e5a887..ddab86a 100644 --- a/MySQLdb/cursors.py +++ b/MySQLdb/cursors.py @@ -26,7 +26,7 @@ restr = r""" (?: (?:\( # ( - editor hightlighting helper - [^)]* + .* \)) | ' From 0beb712e4bd520cfae0308213ee3c55582970477 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Fri, 25 Oct 2013 18:29:15 +0900 Subject: [PATCH 14/20] remove -lmysqlclient when static linking. --- setup_posix.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup_posix.py b/setup_posix.py index f7cb588..cfcf33c 100644 --- a/setup_posix.py +++ b/setup_posix.py @@ -71,8 +71,9 @@ def get_config(): if i.startswith(compiler_flag('I')) ] if static: - extra_objects.append(os.path.join( - library_dirs[0],'lib%s.a' % client)) + extra_objects.append(os.path.join(library_dirs[0],'lib%s.a' % client)) + if client in libraries: + libraries.remove(client) name = "MySQL-python" if enabled(options, 'embedded'): From 87d1145c0d6ee4f5a8ecf6d5c62d2479b9cf27ea Mon Sep 17 00:00:00 2001 From: Guillaume Bandet Date: Mon, 4 Nov 2013 16:17:57 +0100 Subject: [PATCH 15/20] Fix the conversion of list or tuple args to a SQL. When there is one element on the list, the generated SQL was (1,) (python notation of a single element tuple, which is not valid in SQL. --- MySQLdb/converters.py | 7 +++++-- MySQLdb/cursors.py | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/MySQLdb/converters.py b/MySQLdb/converters.py index 491d49b..26c1f90 100644 --- a/MySQLdb/converters.py +++ b/MySQLdb/converters.py @@ -129,13 +129,16 @@ def char_array(s): def array2Str(o, d): return Thing2Literal(o.tostring(), d) +def quote_tuple(t, d): + return "(%s)" % (','.join(escape_sequence(t, d))) + conversions = { IntType: Thing2Str, LongType: Long2Int, FloatType: Float2Str, NoneType: None2NULL, - TupleType: escape_sequence, - ListType: escape_sequence, + TupleType: quote_tuple, + ListType: quote_tuple, DictType: escape_dict, InstanceType: Instance2Str, ArrayType: array2Str, diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py index 7e5a887..8815b80 100644 --- a/MySQLdb/cursors.py +++ b/MySQLdb/cursors.py @@ -180,7 +180,10 @@ class BaseCursor(object): if isinstance(query, unicode): query = query.encode(db.unicode_literal.charset) if args is not None: - query = query % db.literal(args) + if isinstance(args, dict): + query = query % {key: db.literal(item) for key, item in args.iteritems()} + else: + query = query % tuple([db.literal(item) for item in args]) try: r = None r = self._query(query) From 8bef3359fb27b63cf608a6685a99ed77fa766e5a Mon Sep 17 00:00:00 2001 From: Guillaume Bandet Date: Tue, 5 Nov 2013 11:01:22 +0100 Subject: [PATCH 16/20] Syntax fix for python 2.5 support. --- MySQLdb/cursors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py index 8815b80..9797d4a 100644 --- a/MySQLdb/cursors.py +++ b/MySQLdb/cursors.py @@ -181,7 +181,8 @@ class BaseCursor(object): query = query.encode(db.unicode_literal.charset) if args is not None: if isinstance(args, dict): - query = query % {key: db.literal(item) for key, item in args.iteritems()} + query = query % dict((key, db.literal(item)) + for key, item in args.iteritems()) else: query = query % tuple([db.literal(item) for item in args]) try: From 8096d8c0530b6c5ccec671c4746d0f94b4831790 Mon Sep 17 00:00:00 2001 From: Guillaume Bandet Date: Tue, 5 Nov 2013 11:34:43 +0100 Subject: [PATCH 17/20] Also fix executemany(). --- MySQLdb/cursors.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py index 9797d4a..7c01870 100644 --- a/MySQLdb/cursors.py +++ b/MySQLdb/cursors.py @@ -240,7 +240,13 @@ class BaseCursor(object): e = m.end(1) qv = m.group(1) try: - q = [ qv % db.literal(a) for a in args ] + q = [] + for a in args: + if isinstance(a, dict): + q.append(qv % dict((key, db.literal(item)) + for key, item in a.iteritems())) + else: + q.append(qv % tuple([db.literal(item) for item in a])) except TypeError, msg: if msg.args[0] in ("not enough arguments for format string", "not all arguments converted"): From 100485f627be833caa11e68e4cf11d89db5fcd86 Mon Sep 17 00:00:00 2001 From: "jinuk84.kim" Date: Fri, 8 Nov 2013 11:51:31 +0900 Subject: [PATCH 18/20] microsecond-bug-fix for datetime.datetime --- MySQLdb/times.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MySQLdb/times.py b/MySQLdb/times.py index f3a92d7..4040f8e 100644 --- a/MySQLdb/times.py +++ b/MySQLdb/times.py @@ -51,7 +51,11 @@ def DateTime_or_None(s): try: d, t = s.split(sep, 1) - return datetime(*[ int(x) for x in d.split('-')+t.split(':') ]) + if '.' in t: + t, m = t.split('.',1) + else: + m = 0 + return datetime(*[ int(x) for x in d.split('-')+t.split(':')+[m] ]) except (SystemExit, KeyboardInterrupt): raise except: From fb1c79d85a87345525ba82cfdca470c4ef565a3c Mon Sep 17 00:00:00 2001 From: Jinuk Date: Fri, 8 Nov 2013 12:18:55 +0900 Subject: [PATCH 19/20] microsecond-bug-fix When the MySQL Datetime Fraction is less than 6, microseconds set incorrectly. For example, you set the field, Datetime(3). Then this library read the time `2013-11-07 10:27:35.705` as `2013-11-08 10:27:35.000705`. --- MySQLdb/times.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MySQLdb/times.py b/MySQLdb/times.py index 4040f8e..0ff7476 100644 --- a/MySQLdb/times.py +++ b/MySQLdb/times.py @@ -52,10 +52,11 @@ def DateTime_or_None(s): try: d, t = s.split(sep, 1) if '.' in t: - t, m = t.split('.',1) + t, ms = t.split('.',1) + ms = ms.ljust(6, '0') else: - m = 0 - return datetime(*[ int(x) for x in d.split('-')+t.split(':')+[m] ]) + ms = 0 + return datetime(*[ int(x) for x in d.split('-')+t.split(':')+[ms] ]) except (SystemExit, KeyboardInterrupt): raise except: @@ -66,6 +67,7 @@ def TimeDelta_or_None(s): h, m, s = s.split(':') if '.' in s: s, ms = s.split('.') + ms = ms.ljust(6, '0') else: ms = 0 h, m, s, ms = int(h), int(m), int(s), int(ms) @@ -84,6 +86,7 @@ def Time_or_None(s): h, m, s = s.split(':') if '.' in s: s, ms = s.split('.') + ms = ms.ljust(6, '0') else: ms = 0 h, m, s, ms = int(h), int(m), int(s), int(ms) From ed5e9e430d11e93950bfc79a0550bac8ab0f0aa4 Mon Sep 17 00:00:00 2001 From: Andy Dustman Date: Thu, 21 Nov 2013 15:07:08 -0500 Subject: [PATCH 20/20] Update .travis.yml It seems Travis no longer supports Python 2.5. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7676e24..e4fdfda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: python python: - - "2.5" - "2.6" - "2.7" - "pypy"