def _quote(x): if type(x) == types.StringType: x = "'" + string.replace(str(x), "'", "''") + "'" elif type(x) in (types.IntType, types.LongType, types.FloatType): pass elif x is None: x = 'NULL' elif isinstance(x, datetime.date): x = "{d'%04d-%02d-%02d'}" % (x.year, x.month, x.day) elif hasattr(x, '__pg_repr__'): x = x.__pg_repr__() else: #print "didn't like " + x + " " + str(type(x)) raise InterfaceError, 'do not know how to handle type %s' % type(x)