Changeset: 092e2ff52cf1 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=092e2ff52cf1
Modified Files:
clients/python/monetdb/sql/monetize.py
Branch: default
Log Message:
made convertion more flexible to unknown datatypes as long
as they have a string representation
diffs (24 lines):
diff --git a/clients/python/monetdb/sql/monetize.py
b/clients/python/monetdb/sql/monetize.py
--- a/clients/python/monetdb/sql/monetize.py
+++ b/clients/python/monetdb/sql/monetize.py
@@ -22,6 +22,7 @@ functions for converting python objects
import datetime
import decimal
+from monetdb.exceptions import ProgrammingError
def monet_none(data):
"""
@@ -76,4 +77,9 @@ def convert(data):
try:
return mapping[type(data)](data)
except KeyError:
- raise ProgrammingError("type %s not supported as value" % type(data))
\ No newline at end of file
+ if hasattr(data, '__unicode__'):
+ return unicode(data).encode('utf-8')
+ elif hasattr(data, '__str__'):
+ return str(data)
+ else:
+ raise ProgrammingError("type %s not supported as value" %
type(data))
\ No newline at end of file
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list