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 1mX1cb-0005oo-69 for psycopg@arkaria.postgresql.org; Sun, 03 Oct 2021 13:33:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mX1cZ-0000jh-1p for psycopg@arkaria.postgresql.org; Sun, 03 Oct 2021 13:33:39 +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 1mX1cY-0000jY-B9 for psycopg@lists.postgresql.org; Sun, 03 Oct 2021 13:33:38 +0000 Received: from dormouse.elm.relay.mailchannels.net ([23.83.212.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mX1cU-0003P5-Pr for psycopg@postgresql.org; Sun, 03 Oct 2021 13:33:37 +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 262BC341B53 for ; Sun, 3 Oct 2021 13:33:31 +0000 (UTC) Received: from lu-shared04.cpanelplatform.com (100-96-18-141.trex.outbound.svc.cluster.local [100.96.18.141]) (Authenticated sender: cp7oy65bvo) by relay.mailchannels.net (Postfix) with ESMTPA id 39CBF34142A for ; Sun, 3 Oct 2021 13:33:30 +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.96.18.141 (trex/6.4.3); Sun, 03 Oct 2021 13:33:30 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: cp7oy65bvo|x-authuser|paolo@paolodestefani.it X-MailChannels-Auth-Id: cp7oy65bvo X-Ski-Shrill: 3ab46e602ef94295_1633268010802_3841595253 X-MC-Loop-Signature: 1633268010802:3318145739 X-MC-Ingress-Time: 1633268010802 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=HKg/SZWRp2wg7/XIfEeRSt3EJmCCPsY6nvOjR/cFcVE=; b=VKJpOSf4UaHMLiRxirSyb2JyRM vqYYs1I6tmaTbDEiaawBwyJdnRmDEiFqO8POMA+FKbo+C+7ITRZcCoYOcO0O0Kk12diPeBm2/v/sP YfWz2SCM2LCCUGPtW2QLNwJR75BwB/sVXv327tYgidgXu6L9V92KVe5nxIKhllEA6e626ih7pzAFE TkwfnfDX8gOU7Q0cOSr0UMZG3VWtcpRfbCo2M0zmr1IBa5CoCobx600k6aOssGiCiuyM2ddYevYnM TrFgm5fgbnMnTQeyDwIXGqIrmxd+EffiUGZOaXq23DPUCnVbEadSjmg+j+E243eMTUG8wIUqWIkE9 8CQRRWpw==; Received: from [::1] (port=53214 helo=lu-shared04.cpanelplatform.com) by lu-shared04.cpanelplatform.com with esmtpa (Exim 4.94.2) (envelope-from ) id 1mX1cN-00BCIz-I8 for psycopg@postgresql.org; Sun, 03 Oct 2021 15:33:27 +0200 MIME-Version: 1.0 Date: Sun, 03 Oct 2021 15:33:27 +0200 From: Paolo De Stefani To: psycopg@postgresql.org Subject: psycopg3 and cur.description behavior User-Agent: Roundcube Webmail/1.4.11 Message-ID: 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 Hello psycopg users This is my first post on this mailing list I'm an hobbistic user of pythom/postgresql/psycopg. I'm trying to port my application from psycopg2 to psycopg3 beta and i have some problems.. In my application a call a postgresql function that returns some data. The relevant part of the function is this: CREATE OR REPLACE FUNCTION system.pa_connect( pg_version numeric, app_name text, app_version text, app_user_name text, app_user_pwd text, app_client_name text) RETURNS TABLE(session_id integer, app_user character varying, user_description text, is_admin boolean, can_edit_views boolean, can_edit_sortfilters boolean, can_edit_reports boolean, l10n character, tool_button_style character, tab_position character, font_family character varying, font_size integer, icon_theme character varying, style_theme character varying, use_dark_palette boolean, auto_hide_dock boolean, company integer, change_password_required boolean) LANGUAGE 'plpgsql' (...) RETURN QUERY SELECT pg_backend_pid(), c.app_user, u.description, u.is_admin, u.can_edit_views, u.can_edit_sortfilters, u.can_edit_reports, u.l10n, u.tool_button_style, u.tab_position, u.font_family, u.font_size, u.icon_theme, u.style_theme, u.use_dark_palette, u.auto_hide_dock, u.last_company, --system.pa_setting('model_select_limit')::int, change_password_required FROM system.connection c JOIN system.app_user u ON c.app_user = u.code LEFT JOIN system.app_user_company uc ON c.app_user = uc.app_user AND c.company = uc.company WHERE c.session_id = pg_backend_pid(); (...) In my python code i use the return query to create a dictionary in this way: session.update(dict(zip([i[0] for i in cur.description], cur.fetchall()[0]))) This part no longer works in psycopg 3. Looks like cur.description in psycopg 3 is different if i execute a query or call a function. So i tryed to execute this code: cur.execute('SELECT * FROM system.app_user;') print(cur.fetchall()) print(cur.description) And this is the result: [('system', 'pyCOGE system administrator', None, '$2a$06$oFbElI3aMWY7FCY9BiKuf.nJdO.ioGR/oL.MyuNHutKxzv.ib5fgS', datetime.datetime(2021, 9, 21, 19, 9, 40, 352000, tzinfo=datetime.timezone.utc), False, True, True, True, True, True, 'en_US', 10, '10 Prima azienda dimostrativa', datetime.datetime(2021, 10, 1, 8, 2, 41, 708000, tzinfo=datetime.timezone.utc), 'Verdana', 11, 'I', 'N', None, 'oxygen', 'windowsvista', False, True, 'system', datetime.datetime(2021, 9, 21, 19, 9, 40, 320000, tzinfo=datetime.timezone.utc), 'system', datetime.datetime(2021, 10, 1, 8, 2, 41, 708000, tzinfo=datetime.timezone.utc), datetime.datetime(2021, 10, 1, 8, 2, 41, 737965)), ('utente', 'Utente applicativo di pyCOGE', None, '$2a$06$dpNyFb7aiW3xLBkOg8kqX.Vzz0mKuNG72ZpQ5FGLkQZ6iO1K2giHa', datetime.datetime(2021, 9, 21, 19, 9, 40, 361000, tzinfo=datetime.timezone.utc), False, False, False, False, False, False, 'it_IT', 10, '10 Prima azienda dimostrativa', datetime.datetime(2021, 9, 30, 20, 12, 41, 628000, tzinfo=datetime.timezone.utc), 'Arial', 10, 'I', 'N', None, 'oxygen', 'windowsvista', False, False, 'system', datetime.datetime(2021, 9, 21, 19, 9, 40, 320000, tzinfo=datetime.timezone.utc), 'utente', datetime.datetime(2021, 9, 30, 20, 13, 18, 753000, tzinfo=datetime.timezone.utc), datetime.datetime(2021, 9, 30, 20, 13, 18, 753466))] [, , , , , , , , , , , , , , , , , , , , , , , , , , , , ] BUT if i execute (call) the already mentioned postgresql function: cur.execute('SELECT system.pa_connect(%s, %s, %s, %s, %s, %s);', (MRV_PGSQL, APPNAME, APPVERSION, par['user'], par['password'], par['hostname'])) print(cur.fetchall()) print(cur.description) the result is: [(('14120', 'system', 'pyCOGE system administrator', 't', 't', 't', 't', 'en_US', 'I', 'N', 'Verdana', '11', 'oxygen', 'windowsvista', 'f', 't', '10', 'f'),)] [] i don't see the description of each field. what am I doing wrong? How can i get the psycopg2 behavior? Python 3.8.9 on windows 10, postgresql 13, psycopg 3.0 beta1 and sorry for my poor english... -- Paolo De Stefani