[dataimport] Fallback from COPY to executemany (closes #9135780)
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 14 Dec 2015 16:19:52 +0100
changeset 10971 de59a60a9e40
parent 10970 894c14f08380
child 10972 03e8fc9f79a6
[dataimport] Fallback from COPY to executemany (closes #9135780) If we can't build a suitable COPY command (e.g. because data has unsupported type), use executemany instead. Regression introduced in 3.20.0.
dataimport.py
--- a/dataimport.py	Mon Dec 14 12:11:44 2015 +0100
+++ b/dataimport.py	Mon Dec 14 16:19:52 2015 +0100
@@ -380,8 +380,9 @@
                                columns, encoding='utf-8'):
     """ Execute thread with copy from
     """
-    buf = _create_copyfrom_buffer(data, columns, encoding=encoding)
-    if buf is None:
+    try:
+        buf = _create_copyfrom_buffer(data, columns, encoding=encoding)
+    except ValueError:
         _execmany_thread_not_copy_from(cu, statement, data)
     else:
         if columns is None: