pgtoolkit/pgmanager.py
changeset 41 6aad5e35efe8
parent 37 5b0eb4b11940
child 42 9e3775460792
--- a/pgtoolkit/pgmanager.py	Fri Aug 17 11:07:22 2012 +0200
+++ b/pgtoolkit/pgmanager.py	Fri Aug 17 11:14:31 2012 +0200
@@ -147,6 +147,17 @@
         rows = super(Cursor, self).fetchall()
         return [self.row_dict(row, lstrip) for row in rows]
 
+    def adapt(self, row):
+        if isinstance(row, RowDict):
+            # dict
+            adapted = RowDict()
+            for key in row.keys():
+                adapted[key] = self.mogrify('%s', [row[key]]).decode('utf8')
+        else:
+            # list
+            adapted = [self.mogrify('%s', [x]).decode('utf8') for x in row]
+        return adapted
+
     def fetchone_adapted(self, lstrip=None):
         '''Like fetchone_dict() but values are quoted for direct inclusion in SQL query.