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 1kr9t2-0001di-QZ for psycopg@arkaria.postgresql.org; Mon, 21 Dec 2020 01:21:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kr9t1-0000Dy-Ko for psycopg@arkaria.postgresql.org; Mon, 21 Dec 2020 01:21:19 +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 1kr9t1-0000Dp-Fq for psycopg@lists.postgresql.org; Mon, 21 Dec 2020 01:21:19 +0000 Received: from p3plsmtpa06-08.prod.phx3.secureserver.net ([173.201.192.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kr9sw-0003TR-J2 for psycopg@lists.postgresql.org; Mon, 21 Dec 2020 01:21:18 +0000 Received: from DESKTOPPBOKT6J ([98.38.100.21]) by :SMTPAUTH: with ESMTPSA id r9sukewYzkSrTr9suk1qbH; Sun, 20 Dec 2020 18:21:12 -0700 X-CMAE-Analysis: v=2.4 cv=JvE0EO0C c=1 sm=1 tr=0 ts=5fdff889 a=tZXnaF/PLMojNGgMD7Zm7A==:117 a=tZXnaF/PLMojNGgMD7Zm7A==:17 a=IkcTkHD0fZMA:10 a=SNL7wKpgAAAA:8 a=C-sdMEEzAAAA:8 a=epTmVMiNAAAA:8 a=ccRmyzLzgHknUSlQjHUA:9 a=QEXdDO2ut3YA:10 a=uEXi9pYaZPHPrIM342IW:22 a=7WAne9lm5b0o3WrbkWlm:22 a=ndEWmUVY6Yapc0oHF_P4:22 X-SECURESERVER-ACCT: hagen@datasundae.com From: To: "'Adrian Klaver'" , , References: <0bef01d6cce4$987d8120$c9788360$@datasundae.com> <5c55fb91-0b03-2077-fce7-38f2dcc0d402@aklaver.com> <0bf801d6cce8$011969d0$034c3d70$@datasundae.com> <63f9baec-b185-3278-e8a7-84692579f9d8@aklaver.com> In-Reply-To: Subject: RE: BACK: Inserting a variable into cur.execute statement Date: Sun, 20 Dec 2020 18:21:11 -0700 Message-ID: <1a5001d6d737$91f209e0$b5d61da0$@datasundae.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJo2ByQlIUQoUmlPw+s83H/ns7RlQIr5Xh8AbQDjf0A356bEAKbJZSIAolmMdOojZ5AgA== Content-Language: en-us X-CMAE-Envelope: MS4xfA/YhkTNUwzFe4TUS9agm5QWjebzBt94PT6He1Px00AfRhhHW3rvHsR8xDPGv9FH6X+9mWX9Bg54Yn/0GYT2Qikv62Ljjw1/WycAuTRC1FAnAH4jEtcI Mbt/Lq+VB3oWoPKzZEPP+MXGelBtpLhgUpHqH2C1zX3e2nqtqOe9f3aJfjDzmhH/b6c+NqoMf3doTvCSTdBQY+aceIfS8vOI4FTJWU3yEVax366KwSi8f34k Icfe5Uu+19Ddt+KM3Gbowe25wHThjeAyUV3eOaqdji0= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Interesting - thank you Adrian. -----Original Message----- From: Adrian Klaver =20 Sent: Sunday, December 20, 2020 5:57 PM To: Hagen Finley ; psycopg@lists.postgresql.org; = psycopg@postgresql.org Subject: Re: BACK: Inserting a variable into cur.execute statement On 12/20/20 3:13 PM, Hagen Finley wrote: > Hello, >=20 > I finally got around to trying to implement this code and I am running = > into an "IndexError: tuple index out of range" problem. >=20 > I am running a function with parameters from a list: >=20 > def def_acct_analysis(sht,acct): > print(param[par][0]) > print(param[par][1]) > sheet =3D"sheet"+str(sht) > print(sheet) > account =3D acct > print(account) >=20 > par =3D0 param =3D [(1,'ACCT0'),(2,'ACCT1'),(3,'ACCT2'),] >=20 > for pin param: > def_acct_analysis(param[par][0], param[par][1]) >=20 > par +=3D1 FYI, the above can be simplified to: param =3D [(1,'ACCT0'),(2,'ACCT1'),(3,'ACCT2'),] for p in param: def_acct_analysis(p[0], p[1]) >=20 > #Print statements above output: >=20 -- Adrian Klaver adrian.klaver@aklaver.com