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 1nVMSU-00024t-3e for psycopg@arkaria.postgresql.org; Fri, 18 Mar 2022 23:56:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nVMSS-00020S-OW for psycopg@arkaria.postgresql.org; Fri, 18 Mar 2022 23:56:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nVMSS-00020J-6Z for psycopg@lists.postgresql.org; Fri, 18 Mar 2022 23:56:36 +0000 Received: from dormouse.elm.relay.mailchannels.net ([23.83.212.50]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nVMSP-0008MG-1z for psycopg@postgresql.org; Fri, 18 Mar 2022 23:56:34 +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 08BE68012A1 for ; Fri, 18 Mar 2022 23:56:31 +0000 (UTC) Received: from lu-shared04.cpanelplatform.com (unknown [127.0.0.6]) (Authenticated sender: cp7oy65bvo) by relay.mailchannels.net (Postfix) with ESMTPA id 2B8E28014B9 for ; Fri, 18 Mar 2022 23:56:30 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1647647790; a=rsa-sha256; cv=none; b=yrjKl4SJh/FUQr5MJQnAaMezNGWBjCpDldGDCDtUyFLdqNxR3YPNkyUzsP0kKR+ILw93h4 mlNDjZKXvotAXUTSFmAYko+krtHVFBV5rwRkimKpOqPH0wgW1IKIsLlNb3BWYyUtnUgCN8 cKASUhV2gOaA+etN4SbncT61CeOdk7TleMme8P6ux67/uB0rNmeUUOj1dS1mZPHh3Yb2As 3l7SwQ1ZLLADxlFaSrRrn1uHpYipUi5x16gZsK5GswhGCXGa9yAWpcRC3+Bk2ySfMnkz2H WclPhlgPkXSQFthuuZh7sjRPIvfbV46bNPbWhDKYd1WCvDaOq4TWL62Azk+ZZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1647647790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=gU8gnpsY4ZTuLv2Q1K03Jl9kjoOpb6yAk46Dckc8bwI=; b=h0sONAeoaG22CB6iT9WTSNDg67/dK9Fcl4rwo7VbnNdrsHS0dBvMpwZdGh+xTQZKfRaeW4 YiXXUjEI7diZCYwPqvb5u1sxh5xqQvpnxHTIjfITqCz6mD/mHW7bEDSXP7cq5n4vZMsAGj iZQWPJRpogLpY0ErvCwGqmgH4lUPehFukYezOnAF9F1hHC2H/lqkvwcTE2DpWcYDh4dxHe pCcSqqvNuAL8bs+fXw7F2rNhK21Ww7C64FYpmB81eVChIQ5NkZ84siz1pqS/sFauwry6tW rio4KyDHXbp6xy4Mo+Y/GzIvdJ5Gl7uazp/04qtr7lnHfvlJn11I9pZPgUJbfg== ARC-Authentication-Results: i=1; rspamd-74bfb75fc6-qfmkl; auth=pass smtp.auth=cp7oy65bvo smtp.mailfrom=paolo@paolodestefani.it 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.121.210.153 (trex/6.5.3); Fri, 18 Mar 2022 23:56:30 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: cp7oy65bvo|x-authuser|paolo@paolodestefani.it X-MailChannels-Auth-Id: cp7oy65bvo X-Drop-Macabre: 3fdbc2926d42c2d7_1647647790715_1124376007 X-MC-Loop-Signature: 1647647790714:723862002 X-MC-Ingress-Time: 1647647790714 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=gU8gnpsY4ZTuLv2Q1K03Jl9kjoOpb6yAk46Dckc8bwI=; b=kOyDp5XjsrsV67oafMcNGt45QS fjsfH3rOKpVCdPL213pIsJwEsMPxoTZBnNFvgLRrs8UJTuCFNG6BL7DqgEvwJTbg4RKU44DpuuVxE A4I3xlGeDf+ETCtffcPnxjYAvUMTWhrf/5qa01XLy604M7lxJsqPOT8OMINtue8amZLlFniIUUqB5 316d1aOiUzY4YP8RsSgMpf43l4LFC388aF2n2owsNaGt0dz0TZ8b7lidzfzuk2ehnLDF52O/synS3 T7R9MlTQk80KKXWP3k2d3PFNRm+uzUisjwJDTzI34Ylqr/CH97kHoWxkyYZRsjRPnfEY7/F29XPHM PSQbITEg==; Received: from [::1] (port=46698 helo=lu-shared04.cpanelplatform.com) by lu-shared04.cpanelplatform.com with esmtpa (Exim 4.95) (envelope-from ) id 1nVMSK-005mCZ-3W for psycopg@postgresql.org; Sat, 19 Mar 2022 00:56:28 +0100 MIME-Version: 1.0 Date: Sat, 19 Mar 2022 00:56:28 +0100 From: Paolo De Stefani To: Psycopg Subject: Query with boolean parameter User-Agent: Roundcube Webmail/1.4.12 Message-ID: <8df15d1263aaa1a9d36eacb0e5b9a28e@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 Regarding query and parameter binding in psycopg3: cur.execute('SELECT * FROM system.app_user WHERE can_edit_views = %s', (True,)) cur.execute('SELECT * FROM system.app_user WHERE can_edit_views IS %s', (True,)) Traceback (most recent call last): Python Shell, prompt 10, line 1 # Used internally for debug sandbox under external interpreter File "C:\Python310\Lib\site-packages\psycopg\cursor.py", line 555, in execute raise ex.with_traceback(None) psycopg.errors.SyntaxError: syntax error at or near "$1" LINE 1: SELECT * FROM system.app_user WHERE can_edit_views IS $1 ^ Is there any reason why the second query results in a syntax error? I can use the first form but usually to check a boolean or null value in SQL the IS [true|false|null]/ IS NOT [true|false|null] operator is used. -- Paolo De Stefani