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 1kmObv-0007J1-2Q for psycopg@arkaria.postgresql.org; Mon, 07 Dec 2020 22:03:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kmObt-0004Aq-S6 for psycopg@arkaria.postgresql.org; Mon, 07 Dec 2020 22:03:57 +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 1kmObt-0004Ai-N3 for psycopg@lists.postgresql.org; Mon, 07 Dec 2020 22:03:57 +0000 Received: from [66.111.4.26] (helo=out2-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmObr-000819-6X for psycopg@lists.postgresql.org; Mon, 07 Dec 2020 22:03:56 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 667865C02D0; Mon, 7 Dec 2020 17:03:44 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 07 Dec 2020 17:03:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=s Hk814Sd0TvmsErlSLs2bMHESlrqnxEPp0Uhj0Fbs6s=; b=gtfR2DFqKrOlrFV+C S/H1ZAvQphzU0lYOoli/qb//kBQH+HMZ4MPbaNRfDwZQC4K2RDoaQ8kvYy02PlMM D80frpSeuHI17egk9EgdchGazhIE3pyKxMcPesQD3pL7xL2U494TvpoYab9lsPxH CIIS7Cfd673LHD0jVDDETwBnaS+0b4kSdCXbF1rPc4+gk2jFLKzxe0efU/9HlLza kFwIKCSmYpFWfgpfQn8QsiWXrxDHSHrRundLXjjgr1uZFCpUfkvFb7vu5KUcKioH EvmMD+3Dj68/mWAXA5/hz8QcF+PUFbfIF4om1sHIVygr2gwSEmnDyj4h918twOLD 8SGBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=sHk814Sd0TvmsErlSLs2bMHESlrqnxEPp0Uhj0Fbs 6s=; b=e/BSsRJiH6HxyBwC32as8jDIpv2HRw+2ste3KgXwwNVBMXqbFBN1wKxsY tnadiQEXg7hgMvH44hmfRvoL4FC5Vr0S7pIEl+ARq8ywpLFF+iAh3jj/jXACR8F2 0u1sLDUCvNwVDDTKOv19v/icqZ5Q8EGxyC90lQ3xZYuYjCecy+Mw3zLs2mNtUbrl 4+1VHArEWDjoKt0VKxtNKrWS8TFAfn2EIeczADNFyEUY3QoT6yk9fxRXcmul1zOW OZtaEbff9dKS+m9h32ydmQulgSkhj50PxPA0Yekwp9yr13yRDGdyx4fe9OaH+KWs NWfKoJJoUvKSVYazxvq2GlWozYBdw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudejgedgudehiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesth ejredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdr khhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeejgfeiie eivdeuheevkeekkeejvedtgeeihffhvdffheeiheeltdekveetieehjeenucffohhmrghi nhepphhshigtohhpghdrohhrghenucfkphepjeehrddujedvrddurdeileenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.4] (75-172-1-69.tukw.qwest.net [75.172.1.69]) by mail.messagingengine.com (Postfix) with ESMTPA id 4628B108006A; Mon, 7 Dec 2020 17:03:43 -0500 (EST) Subject: Re: Inserting variable into To: hagen@datasundae.com, psycopg@lists.postgresql.org, psycopg@postgresql.org References: <0bef01d6cce4$987d8120$c9788360$@datasundae.com> From: Adrian Klaver Message-ID: <5c55fb91-0b03-2077-fce7-38f2dcc0d402@aklaver.com> Date: Mon, 7 Dec 2020 14:03:42 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <0bef01d6cce4$987d8120$c9788360$@datasundae.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.26 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/7/20 2:02 PM, hagen@datasundae.com wrote: > Hello, > > I'd like to use a variable for 'Big Company' (e.g. account) or where = statements generally in my cur.execute statements: > > cur.execute("SELECT SUM(revusd) FROM sfdc where saccount = 'Big Company' AND stage LIKE 'Commit%';") > commitd1 = cur.fetchone() > conn.commit() > > but I don't know the proper syntax with the cur.execute statement to use a variable. https://www.psycopg.org/docs/usage.html#passing-parameters-to-sql-queries > > I imagine others do - thanks! > > Best, > > Hagen > > > -- Adrian Klaver adrian.klaver@aklaver.com