]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Shorten traceback on executemany
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 2 Jan 2022 19:06:45 +0000 (20:06 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 2 Jan 2022 19:58:00 +0000 (20:58 +0100)
psycopg/psycopg/cursor.py
psycopg/psycopg/cursor_async.py

index 64798485b71b761dbd4f57885d2e7333fce3ce8f..fb71d9d51808e40c123acb570774c932ff377768 100644 (file)
@@ -567,8 +567,11 @@ class Cursor(BaseCursor["Connection[Any]", Row]):
         """
         Execute the same command with a sequence of input data.
         """
-        with self._conn.lock:
-            self._conn.wait(self._executemany_gen(query, params_seq))
+        try:
+            with self._conn.lock:
+                self._conn.wait(self._executemany_gen(query, params_seq))
+        except e.Error as ex:
+            raise ex.with_traceback(None)
 
     def stream(
         self,
index f9d7109db0baae9cedf6721ceff3340124f85772..1e34bef65f2dcb48e3acbe71f64eff39a72085c5 100644 (file)
@@ -84,8 +84,11 @@ class AsyncCursor(BaseCursor["AsyncConnection[Any]", Row]):
     async def executemany(
         self, query: Query, params_seq: Iterable[Params]
     ) -> None:
-        async with self._conn.lock:
-            await self._conn.wait(self._executemany_gen(query, params_seq))
+        try:
+            async with self._conn.lock:
+                await self._conn.wait(self._executemany_gen(query, params_seq))
+        except e.Error as ex:
+            raise ex.with_traceback(None)
 
     async def stream(
         self,