diff --git a/swh/core/db/__init__.py b/swh/core/db/__init__.py --- a/swh/core/db/__init__.py +++ b/swh/core/db/__init__.py @@ -74,17 +74,12 @@ def adapt_conn(cls, conn): """Makes psycopg2 use 'bytes' to decode bytea instead of 'memoryview', for this connection.""" - cur = conn.cursor() - cur.execute("SELECT null::bytea, null::bytea[]") - bytea_oid = cur.description[0][1] - bytea_array_oid = cur.description[1][1] - t_bytes = psycopg2.extensions.new_type( - (bytea_oid,), "bytea", typecast_bytea) + (17,), "bytea", typecast_bytea) psycopg2.extensions.register_type(t_bytes, conn) t_bytes_array = psycopg2.extensions.new_array_type( - (bytea_array_oid,), "bytea[]", t_bytes) + (1001,), "bytea[]", t_bytes) psycopg2.extensions.register_type(t_bytes_array, conn) @classmethod