Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vKg3R-004Sd7-1e for psycopg@arkaria.postgresql.org; Sun, 16 Nov 2025 16:56:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vKg3P-00B22U-09 for psycopg@arkaria.postgresql.org; Sun, 16 Nov 2025 16:56:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vKg3O-00B22J-2j for psycopg@lists.postgresql.org; Sun, 16 Nov 2025 16:56:42 +0000 Received: from smtp66.iad3a.emailsrvr.com ([173.203.187.66]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vKg3M-00841O-1U for psycopg@lists.postgresql.org; Sun, 16 Nov 2025 16:56:42 +0000 X-Auth-ID: xof@thebuild.com Received: by smtp25.relay.iad3a.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id 51849251EE for ; Sun, 16 Nov 2025 11:56:38 -0500 (EST) From: Christophe Pettus Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51.11.4\)) Subject: Overriding default adapters in psycopg Message-Id: Date: Sun, 16 Nov 2025 08:56:07 -0800 To: psycopg@lists.postgresql.org X-Mailer: Apple Mail (2.3776.700.51.11.4) X-Classification-ID: 50b6b0dc-e12e-465f-9227-64e16b0f114c-1-1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi! I am attempting to override the default adapters for JSON and JSONB in = psycopg (3), but I am not quite sure how to go about it (I'm testing = using orjson for serialization and deserialization). This doesn't = appear to work: > class CyanJSONBLoader(Loader): > def load(self, data): > return orjson.loads(data) >=20 > psycopg.adapters.register_loader("jsonb", CyanJSONBLoader) >=20 > class CyanJSONBDumper(Dumper): > def dump(self, obj): > return orjson.dumps(obj) >=20 > psycopg.adapters.register_dumper("jsonb", CyanJSONBDumper) >=20 The calls work, but the dump/load functions are never called. Thanks!=