Am 14.12.2018 um 14:57 schrieb Justin Pryzby:
> Maybe it's easier than that..
> I saw two issues. First, EXECUTE %s wasn't "adapted" to $1 (since
> there were no parameters passed).
> Second, execute failed with inline=False.
> But actually, SQL EXECUTE doesn't accept parameters,
> they MUST be inline.
> https://www.postgresql.org/docs/11/sql-execute.html
That second issue seems to be correct - it only works when the
parameters in SQL EXECUTE are sent inline. But I don't see where this is
mentioned in the link you posted above, and I don't see your first
issue. It works for me without having to adapt the prepare statement.
Just use Postgres params:
db.query(
'prepare c AS INSERT INTO tweets VALUES($1,$2,$3)')
db.query_formatted(
'execute c(%s,%s,%s)', [45, 'trump', 'so sad'], inline=True)
So it seems with this workaround we can actually use prepared
statements. We should probably mention this in the documentation.
-- Christoph
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo/pygresql