[DB-SIG] Context manager support for cursors
Daniele Varrazzo
daniele.varrazzo at gmail.com
Thu Jul 26 09:45:18 EDT 2018
On Thu, Jul 26, 2018 at 2:18 PM, Mike Bayer <mike_mp at zzzcomputing.com> wrote:
Oh hi! If there is someone who has experience in how much effort it
takes to beat every different driver into submission that's you :)
>> - should execute(query) with no param go for a round of placeholders
>> escape on the string as it would execute(query, {})?
> I think I know what issue you're talking about. This seems much
> more subtle of an issue than we would normally see in a pep-249 which
> is overall very terse about each point.
Still a baffling thing...
- HAL, retrieve the even records please.
- cursor.execute("select * from students where id % 2 = 0")
- Now please retrieve only the ones born after the date D.
- cursor.execute("select * from students where id % 2 = 0 and dob >= %s", [D])
(some mysterious traceback)
- Open the pod bay doors, HAL.
I'd rather force people to specify % as %% regardless of the presence
of parameters (in the case of other driver the problem would be with
other characters - question marks, colons... - but it's probably the
same).
>> - placeholders style, of course...
>
> one positional and one named and that's it ....Annnnndddd:
Maybe it's easy enough to use the most generic one ("%s" and
"%(name)s"? "{}" and "{name}"?) and provide a conversion library to
help implementing drivers using whatever different format they have to
use?
> - prepared statements
>
> I don't recall if I was for or against this being in the spec.
> Seems like something that should be clarified though.
Yes!
-- Daniele
More information about the DB-SIG
mailing list