public inbox for [email protected]
help / color / mirror / Atom feedFrom: Lembark, Steven <[email protected]>
To: [email protected] <[email protected]>
Cc: Loga, Dharani <[email protected]>
Subject: Using standard SQL placeholders in PG
Date: Wed, 13 Oct 2021 13:11:14 +0000
Message-ID: <BN0PR20MB391249E4640F43A8A14B84A4FDB79@BN0PR20MB3912.namprd20.prod.outlook.com> (raw)
PostgreSQL ("PG") supports the notion of placeholders, as do many other relational databases. The placeholder notation in PG uses $X within the SQL. For example:
select foo
from bar
where bletch = $1
is valid SQL. The doller-notation allows re-use of positional parameters and avoids SQL injection entirely by placing the input is appropriately-typed buffers w/in the SQL statement handler. It also avoids issues with double-interpolating quotes as the placeholders are not literals and do not require SQL-quoting to be interpolated properly.
We have quite a bit of SQL here that has to be shared between Python and other packages, so using standard PG SQL statements is required.
Q: Is there any way to prepare and execute standard PG SQL statements with dollar placeholders in PsychoPG2?
Thanks
This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.
view thread (2+ messages) latest in thread
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: Using standard SQL placeholders in PG
In-Reply-To: <BN0PR20MB391249E4640F43A8A14B84A4FDB79@BN0PR20MB3912.namprd20.prod.outlook.com>
* 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