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 1jdYUu-0007SJ-Ld for psycopg@arkaria.postgresql.org; Tue, 26 May 2020 12:15:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jdYUt-0007O9-KS for psycopg@arkaria.postgresql.org; Tue, 26 May 2020 12:15:55 +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 1jdYUt-0007Nz-FD for psycopg@lists.postgresql.org; Tue, 26 May 2020 12:15:55 +0000 Received: from securemail-y25.synaq.com ([196.35.198.11]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jdYUq-0002ut-IL for psycopg@postgresql.org; Tue, 26 May 2020 12:15:54 +0000 Received: from [197.90.32.26] (helo=[192.168.0.8]) by securemail-pl-omx11.synaq.com with esmtpa (Exim 4.92.3) (envelope-from ) id 1jdYUZ-000Rvg-GU for psycopg@postgresql.org; Tue, 26 May 2020 14:15:35 +0200 Subject: Re: Minor issue To: psycopg@postgresql.org References: <92a25cd6-5b50-3074-0da6-7394db9e0f0a@chagford.com> From: Frank Millman Message-ID: <3f076465-0e4f-ff6b-6a7b-51ba7daf3bc3@chagford.com> Date: Tue, 26 May 2020 14:15:29 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SYNAQ-Pinpoint-Information: Please contact SYNAQ for more information X-SYNAQ-Pinpoint-ID: 1jdYUZ-000Rvg-GU X-SYNAQ-Pinpoint: Found to be clean X-SYNAQ-Pinpoint-SpamCheck: not spam, SpamAssassin (not cached, score=-1.1, required 9, autolearn=disabled, ALL_TRUSTED -1.00, DCC_REPUT_13_19 -0.10) X-Pinpoint-From: frank@chagford.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ok, thanks. Frank On 2020-05-26 2:11 PM, Daniele Varrazzo wrote: > No, we don't want to add any intelligence in trying to figure out what > is into a query. If you are comfortable that you will be using always > the same pattern for comments you can easily clean the string yourself > before passing it to psycopg. > > A better approach for you I guess would be to use named placeholders, > so that an a missing placeholder wouldn't require you to change the > arguments to execute. > > -- Daniele > > On Tue, 26 May 2020 at 23:43, Frank Millman wrote: >> >> Hi all >> >> This is very minor, but I thought I would mention it. >> >> I have a function that returns a complex SQL query and a tuple of >> parameters. The query is stored inside the function as a triple-quoted >> string, and the parameters are derived depending on the input arguments. >> >> Sometimes while testing I will comment out some of the SQL using '--'. >> If those lines happen to contain a parameter placeholder ('%s') I >> expected to remove the parameter from the tuple as well. >> >> pyodbc and sqlite3 both work this way, but psycopg2 raises the exception >> 'tuple index out of range'. >> >> I can live with it, but it means that I have to adjust the parameter >> tuple differently depending on which database I am testing with. >> >> If it can be fixed, that would be nice. If it can't, no problem. >> >> Frank Millman >> >>