public inbox for [email protected]
help / color / mirror / Atom feedFrom: Rory Campbell-Lange <[email protected]>
To: Frank Millman <[email protected]>
Cc: [email protected]
Subject: Re: Minor issue
Date: Tue, 26 May 2020 15:09:36 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<CA+mi_8YDBvXkns7odQQ5VLATyCXe2xFTw_KV5H19Q9aTyWEEog@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
On 26/05/20, Frank Millman ([email protected]) wrote:
>
>
> On 2020-05-26 3:08 PM, Rory Campbell-Lange wrote:
> > On 26/05/20, Frank Millman ([email protected]) wrote:
> > Does using %s instead of {}.format help solve the issue?
>
> To reproduce my situation, you should place the '--' at the beginning of the
> following line (',%s as d').
>
> As no parameters are now being substituted, I would expect to supply an
> empty tuple. In fact, the parameter is still required.
That makes sense, apologies.
However, this works as you suggest:
In [33]: d.query("""
...: select
...: 1 as a
...: /*
...: ,2 as b
...: */
...: -- ,'hi' as c
...: -- ,%s as d
...: """, ("a string", )).results
Out[33]: [Record(a=1)]
This doesn't work (as you suggest):
In [35]: d.query("""
...: select
...: 1 as a
...: /*
...: ,2 as b
...: */
...: -- ,'hi' as c
...: -- ,%s as d
...: """, ()).results
ERROR:root:An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line string', (1, 0))
But this works:
In [34]: d.query("""
...: select
...: 1 as a
...: /*
...: ,2 as b
...: */
...: -- ,'hi' as c
...: -- ,%s as d
...: """).results
Out[34]: [Record(a=1)]
So perhaps simply don't provide the tuple in this case? This will also probably
work for your other backends.
Rory
view thread (8+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Minor issue
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox