Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p8YCa-0002ve-FX for psycopg@arkaria.postgresql.org; Fri, 23 Dec 2022 02:54:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p8YCY-0000AK-Vz for psycopg@arkaria.postgresql.org; Fri, 23 Dec 2022 02:54:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p8YCY-0000A1-Mk for psycopg@lists.postgresql.org; Fri, 23 Dec 2022 02:54:26 +0000 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p8YCR-00031L-Qd for psycopg@lists.postgresql.org; Fri, 23 Dec 2022 02:54:25 +0000 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-1445ca00781so4701163fac.1 for ; Thu, 22 Dec 2022 18:54:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zscaler.com; s=google; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=YuZV1GCySqP5CmhIOLegRBAbhiD0GxKx9ynB7dlrqp4=; b=hxgGN6KYScuvjtX2+6/YjyeAwtbgnUOen5/12DPc44tf2NIL8ByEFQCp8b5R7ZsrRD A6bsv952Imj85pXcSTO4qhOkDZAZ6/0U+bTylKGpk7nWNQNvij0dpNu6gJGyGM/M7GOq CplxR3c9IiCosC5O4oVm87q57hG1HUVyiC6VE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=YuZV1GCySqP5CmhIOLegRBAbhiD0GxKx9ynB7dlrqp4=; b=qvEEwxoQDlLxoKFtNDCqfPhtgylyMtN7olNf42Cenxyd6ovB0/RPxCNgL+Ksb+mGjb nNf6tW3FVbqXMpS3bkVZZGKLgfIonsZyOWqi2olDcyitqJbCcBv3CU+tvECxXX2YYKPK I+Np6PorEZrG2kDqJfSWocFVmRq7VzUgv+m36NvVrscRdYc3vFz55JbP2C4dEOmTUDvU svYLU6n693cy+cBFjS5nZDIsQ2/anvfEmEB320FUBQGCEISq1gVMJ/nleknLrPqCd0zV KVA0rzdy88RNPT1o2ppMDaTiFckvb5Go4w1JxwG+VSl1q0ZQcD24jmalOyolKumYbrLS obgQ== X-Gm-Message-State: AFqh2kqbUWkzfB5SKG37bAcCECSSTpIYIebhFVHhcNVoPxOuV+rdTY1C w9hMLP5YqDBsx24mfHjNk9h3EWeFdhF3a9fgLRviicLGbRSg2g== X-Google-Smtp-Source: AMrXdXuWtjOLedaSZbi6qUE29dy2AUtgxN4TnlmRkdWT1wgGDAIfB603tRGWBv0HaaW5xOiQj0eepj10ieiY6LNzKRE= X-Received: by 2002:a05:6870:1f0a:b0:144:9310:987b with SMTP id pd10-20020a0568701f0a00b001449310987bmr501466oab.268.1671764058726; Thu, 22 Dec 2022 18:54:18 -0800 (PST) MIME-Version: 1.0 From: Christopher Bader Date: Thu, 22 Dec 2022 21:53:43 -0500 Message-ID: Subject: bug in handling Postgres bytea type? To: psycopg@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000de83bd05f075e654" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000de83bd05f075e654 Content-Type: text/plain; charset="UTF-8" I'm having problems reading bytea fields with psycopg2. Reading a bytea field with cursor.fetchall yields a memoryview object, not a bytes or bytearray object, and even when the object is explicitly converted to bytes or bytearray, the result is not correct. Christopher Bader Staff Data Scientist Zscaler --000000000000de83bd05f075e654 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'm having problems reading bytea fields with psycopg2= .

Reading a bytea field with cursor.fetchall yields a me= moryview object, not a bytes or bytearray object, and even when the object = is explicitly converted to bytes or bytearray, the result is not correct.

Christopher Bader
Staff Data Scientist
Zscaler
--000000000000de83bd05f075e654--