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 1nIZoC-0002EM-SN for psycopg@arkaria.postgresql.org; Fri, 11 Feb 2022 17:34:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIZoB-0002gv-Pd for psycopg@arkaria.postgresql.org; Fri, 11 Feb 2022 17:34:11 +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 1nIZoB-0002gl-5S for psycopg@lists.postgresql.org; Fri, 11 Feb 2022 17:34:11 +0000 Received: from cross.elm.relay.mailchannels.net ([23.83.212.46]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIZo7-0000iw-7r for psycopg@postgresql.org; Fri, 11 Feb 2022 17:34:09 +0000 X-Sender-Id: cp7oy65bvo|x-authuser|paolo@paolodestefani.it Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E1BCF2812A3 for ; Fri, 11 Feb 2022 17:34:02 +0000 (UTC) Received: from lu-shared04.cpanelplatform.com (unknown [127.0.0.6]) (Authenticated sender: cp7oy65bvo) by relay.mailchannels.net (Postfix) with ESMTPA id D170428144E for ; Fri, 11 Feb 2022 17:33:51 +0000 (UTC) X-Sender-Id: cp7oy65bvo|x-authuser|paolo@paolodestefani.it Received: from lu-shared04.cpanelplatform.com ([UNAVAILABLE]. [107.189.4.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.126.0.6 (trex/6.5.3); Fri, 11 Feb 2022 17:34:02 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: cp7oy65bvo|x-authuser|paolo@paolodestefani.it X-MailChannels-Auth-Id: cp7oy65bvo X-Celery-Bored: 3b65e997780b697f_1644600837985_568298024 X-MC-Loop-Signature: 1644600837985:2720901021 X-MC-Ingress-Time: 1644600837985 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=paolodestefani.it; s=default; h=Content-Transfer-Encoding:Content-Type: Message-ID:Subject:To:From:Date:MIME-Version:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=XXRBuYAE+JG+tDLxfS1t1mOvaO4jA1UfwYhXQPWQRVQ=; b=YMQVsNyF1EuO06Q72mtdGTf5rh 30KKFAJmRfAdmRTZWFZsjAYcweVio+NFyKtIhXv2xg2/A0spfiDVs0R69CJzvbcyGxVYXVOiol0mf iVdWM06SsdQi3ovHPpWY9vYurM/PIxU6mkt6ffzOucDNZ4PhPi3GdmJr6SrTZPtuatYIsFu0DsPgX XIu7tQV7scbOmiYQ7yKQjDKZgcDtSKIUJaRjEXhcahZ6bnIrHk4fuwEY/utUZeRb5gz12VhFi7gVd qOOcQUm816y6okmqx2mJKFAFvm5yggkY48IFG9vuEqYOTKZOE1dbo/U5Q+YslKBXYRUVaUFAHVy5T 8XkZWSgw==; Received: from [::1] (port=40554 helo=lu-shared04.cpanelplatform.com) by lu-shared04.cpanelplatform.com with esmtpa (Exim 4.95) (envelope-from ) id 1nIZnf-00068K-Gy for psycopg@postgresql.org; Fri, 11 Feb 2022 18:33:39 +0100 MIME-Version: 1.0 Date: Fri, 11 Feb 2022 18:33:39 +0100 From: Paolo De Stefani To: Psycopg Subject: exception psycopg.Error from psycopg2 to psycopg 3 User-Agent: Roundcube Webmail/1.4.12 Message-ID: <11dedb1fce0dbbd6f125736347685fd5@paolodestefani.it> X-Sender: paolo@paolodestefani.it Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-AuthUser: paolo@paolodestefani.it List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi all Porting my program from psycopg2 to psycopg 3 i found another different behaviour This SQL code inside a function: RAISE EXCEPTION 'Error wrong database' USING HINT = 'You need to use a different database', ERRCODE = 'PA002'; is catched in python code with: try: except psycopg.Error as er: raise PyAppDBError(er.sqlstate, er) With psycopg2 er.sqlstate is set to 'PA002' in psycopg3 is set to None Is this an expected behavour ? Is there a way to get the error code in psycopg3 like it is available in psycopg2 ? Or maybe Am I doing something wrong ? Thanks -- Paolo De Stefani