Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aca3a39

Browse filesBrowse files
authored
Remove old TIMESTAMP format for MySQL<4.1 (PyMySQL#308)
1 parent 80278a2 commit aca3a39
Copy full SHA for aca3a39

File tree

Expand file treeCollapse file tree

3 files changed

+1
-27
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+1
-27
lines changed

‎MySQLdb/converters.py

Copy file name to clipboardExpand all lines: MySQLdb/converters.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def quote_tuple(t, d):
117117
FIELD_TYPE.LONGLONG: int,
118118
FIELD_TYPE.INT24: int,
119119
FIELD_TYPE.YEAR: int,
120-
FIELD_TYPE.TIMESTAMP: mysql_timestamp_converter,
120+
FIELD_TYPE.TIMESTAMP: DateTime_or_None,
121121
FIELD_TYPE.DATETIME: DateTime_or_None,
122122
FIELD_TYPE.TIME: TimeDelta_or_None,
123123
FIELD_TYPE.DATE: Date_or_None,

‎MySQLdb/times.py

Copy file name to clipboardExpand all lines: MySQLdb/times.py
-14Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,3 @@ def DateTime2literal(d, c):
129129
def DateTimeDelta2literal(d, c):
130130
"""Format a DateTimeDelta object as a time."""
131131
return string_literal(format_TIMEDELTA(d))
132-
133-
def mysql_timestamp_converter(s):
134-
"""Convert a MySQL TIMESTAMP to a Timestamp object."""
135-
# MySQL>4.1 returns TIMESTAMP in the same format as DATETIME
136-
if s[4] == '-': return DateTime_or_None(s)
137-
s = s + "0"*(14-len(s)) # padding
138-
parts = map(int, filter(None, (s[:4],s[4:6],s[6:8],
139-
s[8:10],s[10:12],s[12:14])))
140-
try:
141-
return Timestamp(*parts)
142-
except (SystemExit, KeyboardInterrupt):
143-
raise # pragma: no cover
144-
except:
145-
return None

‎tests/test_MySQLdb_times.py

Copy file name to clipboardExpand all lines: tests/test_MySQLdb_times.py
-12Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,6 @@ def test_timestamp_from_ticks(self, mock):
8181
assert times.TimestampFromTicks(1430000000.123) == datetime(2015, 4, 25, 22, 13, 20)
8282

8383

84-
class TestTimestampConverter(unittest.TestCase):
85-
def test_mysql_timestamp_converter(self):
86-
assert times.mysql_timestamp_converter('2015-12-13') == date(2015, 12, 13)
87-
assert times.mysql_timestamp_converter('2038-01-19 03:14:07') == datetime(2038, 1, 19, 3, 14, 7)
88-
89-
assert times.mysql_timestamp_converter('2015121310') == datetime(2015, 12, 13, 10, 0)
90-
assert times.mysql_timestamp_converter('20151213101112') == datetime(2015, 12, 13, 10, 11, 12)
91-
92-
assert times.mysql_timestamp_converter('20151313') is None
93-
assert times.mysql_timestamp_converter('2015-13-13') is None
94-
95-
9684
class TestToLiteral(unittest.TestCase):
9785
def test_datetime_to_literal(self):
9886
assert times.DateTime2literal(datetime(2015, 12, 13), '') == b"'2015-12-13 00:00:00'"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.