From: | Frank Millman <frank(at)chagford(dot)com> |
---|---|
To: | psycopg(at)postgresql(dot)org |
Subject: | Re: Minor issue |
Date: | 2020-05-26 12:15:29 |
Message-ID: | 3f076465-0e4f-ff6b-6a7b-51ba7daf3bc3@chagford.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
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 <frank(at)chagford(dot)com> 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
>>
>>
From | Date | Subject | |
---|---|---|---|
Next Message | Rory Campbell-Lange | 2020-05-26 13:08:01 | Re: Minor issue |
Previous Message | Daniele Varrazzo | 2020-05-26 12:11:34 | Re: Minor issue |