public inbox for [email protected]
help / color / mirror / Atom feedFrom: Christophe Pettus <[email protected]>
To: [email protected]
Subject: Overriding default adapters in psycopg
Date: Sun, 16 Nov 2025 08:56:07 -0800
Message-ID: <[email protected]> (raw)
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)
>
> psycopg.adapters.register_loader("jsonb", CyanJSONBLoader)
>
> class CyanJSONBDumper(Dumper):
> def dump(self, obj):
> return orjson.dumps(obj)
>
> psycopg.adapters.register_dumper("jsonb", CyanJSONBDumper)
>
The calls work, but the dump/load functions are never called.
Thanks!
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Overriding default adapters in psycopg
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox