Hi guys,
I've been using PyGreSQL-4.0 module and I quite like it.
However, it misses support for datetime.date objects and can't correctly
quote floats with nan value. So, I thought you may like to consider adding
the following to pgdb.py:
----------------------- 3rd-party/PyGreSQL-4.0/pgdb.py
------------------------
index b500d3b..47dfe4e 100644
@@ -69,7 +69,7 @@ try:
frozenset
except NameError: # Python < 2.4
from sets import ImmutableSet as frozenset
-from datetime import datetime, timedelta
+from datetime import datetime, timedelta, date
try: # use Decimal if available
from decimal import Decimal
set_decimal(Decimal)
@@ -187,13 +187,16 @@ class pgdbCursor(object):
def _quote(self, val):
"""Quote value depending on its type."""
- if isinstance(val, datetime):
+ if isinstance(val, (datetime, date)):
val = str(val)
elif isinstance(val, unicode):
val = val.encode( 'utf8' )
if isinstance(val, str):
val = "'%s'" % self._cnx.escape_string(val)
- elif isinstance(val, (int, long, float)):
+ elif isinstance(val, float):
+ if val != val:
+ val = "'nan'"
+ elif isinstance(val, (int, long)):
pass
elif val is None:
val = 'NULL'
Maxim
_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql