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 1mXjCN-0002NA-Fn for psycopg@arkaria.postgresql.org; Tue, 05 Oct 2021 12:05:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mXjCM-0005TF-BS for psycopg@arkaria.postgresql.org; Tue, 05 Oct 2021 12:05:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXjCM-0005T7-2o for psycopg@lists.postgresql.org; Tue, 05 Oct 2021 12:05:30 +0000 Received: from mail-ua1-x92f.google.com ([2607:f8b0:4864:20::92f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mXjCK-00025S-8G for psycopg@postgresql.org; Tue, 05 Oct 2021 12:05:29 +0000 Received: by mail-ua1-x92f.google.com with SMTP id u5so11731702uao.13 for ; Tue, 05 Oct 2021 05:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rD3DbdaqvI26V9RPej6XhIIEC8D1mdPV42CLONqI7Lc=; b=RHi/UnkK9DUld63Xc/3lDdiMeZknbT1sYlMtL0jyfwX9Oq6TeRHaOF7PpHkHgbtgiu Oi9A2snRmZ1SBimj14/oKSAgEOQlxguHFBDKmF7fISQXYumDD7I0HSt6M5Re2qkwaiBS crtT5XZQeouEBIFYVKh60uYdCzh+mzYT26+yMINjjmS+qw9/eW1hAMSGgNvC2XTp2TSH dU0ea4CImn+vJWO0LTOtydGCdNWkEZB3xsuWp+BAM/dARMxThfCyUG3xi2E0dS89mccf M2babg0gKOBJs8iDKpXdb87yPpbhQXs5mLyq8wqQC6rdJwzOpOtkKTx6vu3mltc5pZVh u8Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rD3DbdaqvI26V9RPej6XhIIEC8D1mdPV42CLONqI7Lc=; b=lmwsWtEkyVXnbh2a36tzzAg+TWHCtER0e4+wnHiqJi77pifdajpE/wHZGamNa8nh7O olMmS9ubfe8wXS1i6qaw30z+x0blQQuCFOmLldVWwKTxUdjXGuSZwqmwqBWLE27WTfP2 bzAuEuM3GlPQxVi9uS2XJl20yuWFwtxZfqElPYUxQm3kFX7bjAbb9zUlrIZoFZPw9tH7 w6ovh9IMJBDuNY0nMXaMnxyCvjshyJLRQsA2Ni135aBeJ600q48fYkkY6M/gdCM1t9co 4vAl1CeH+lWjYYg3VlsF7RRi2qTwGcJScRpUKNynvwhleNlVxPNdgXTg95tsCO1Pz0+C 4JYg== X-Gm-Message-State: AOAM533tJa26+eVlMbZWBYTeUacZWYCP95m4I6PqGEL5JRBCkA/J3Zcc bARaHpa5iye2AuxALobCdv2d/JrGznkWrBjqlEU= X-Google-Smtp-Source: ABdhPJzl074ICkT1mQgXwlE6LhV076RtAcRxp/6wfc/grkcRYCwByeIe/00qim1UfgQn8vcSTBRDol32OY4DJzUwPGo= X-Received: by 2002:ab0:5b17:: with SMTP id u23mr11183844uae.18.1633435523460; Tue, 05 Oct 2021 05:05:23 -0700 (PDT) MIME-Version: 1.0 References: <4c05fd7ddf571bfc82baeede1449f7f0@paolodestefani.it> In-Reply-To: <4c05fd7ddf571bfc82baeede1449f7f0@paolodestefani.it> From: Daniele Varrazzo Date: Tue, 5 Oct 2021 14:05:12 +0200 Message-ID: Subject: Re: From spycopg2 to psycopg3 data adaptation To: Paolo De Stefani Cc: Psycopg Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 5 Oct 2021 at 13:30, Paolo De Stefani 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: > > > > 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