Re: From spycopg2 to psycopg3 data adaptation - Mailing list psycopg

From Daniele Varrazzo
Subject Re: From spycopg2 to psycopg3 data adaptation
Date
Msg-id CA+mi_8YxxD_CYqLySiSwLJZvwSmgaQHHzyQFdtjfevhYqV6JoQ@mail.gmail.com
Whole thread Raw
In response to From spycopg2 to psycopg3 data adaptation  (Paolo De Stefani <paolo@paolodestefani.it>)
List psycopg
On Tue, 5 Oct 2021 at 13:30, Paolo De Stefani <paolo@paolodestefani.it> wrote:

> class TimestamptzQDateTimeLoader(Loader):
>      def load(self, value):
>          if value is None:
>              return None

A `None` will never make it here: you can drop this check in psycopg 3.


> BUT it's not working because the "value" is binary not string:
>
> <memory at 0x000000000939BA00>
>
> So how i can get the same result of psycopg2 in psycopg3 ?

You can use bytes(value) to get the value as bytes string, and if you
need a str you can use bytes(value).decode()

-- Daniele



psycopg by date:

Previous
From: Paolo De Stefani
Date:
Subject: From spycopg2 to psycopg3 data adaptation
Next
From: Jason Erickson
Date:
Subject: Re: How to build statically on Windows