diff MySQLdb/times.py @ 67:98d968f5af11 MySQLdb

Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
author adustman
date Mon, 30 Mar 2009 20:21:24 +0000
parents 7773efbe9b30
children 228a45771d14
line wrap: on
line diff
--- a/MySQLdb/times.py	Sun Mar 29 16:26:30 2009 +0000
+++ b/MySQLdb/times.py	Mon Mar 30 20:21:24 2009 +0000
@@ -12,7 +12,6 @@
 
 from time import localtime
 from datetime import date, datetime, time, timedelta
-from _mysql import string_literal
 
 # These are required for DB-API (PEP-249)
 Date = date
@@ -192,17 +191,17 @@
     
     """
     try:
-        return date(*[ int(x) for x in obj.split('-', 2) ])
+        return date(*map(int, obj.split('-', 2)))
     except ValueError:
         return None
 
-def datetime_to_sql(obj, conv):
+def datetime_to_sql(connection, obj):
     """Format a DateTime object as an ISO timestamp."""
-    return string_literal(datetime_to_str(obj), conv)
+    return connection.string_literal(datetime_to_str(obj))
     
-def timedelta_to_sql(obj, conv):
+def timedelta_to_sql(connection, obj):
     """Format a timedelta as an SQL literal."""
-    return string_literal(timedelta_to_str(obj), conv)
+    return connection.string_literal(timedelta_to_str(obj))
 
 def mysql_timestamp_converter(timestamp):
     """Convert a MySQL TIMESTAMP to a Timestamp object.