Does pgx implement a way to prevent SQL Injections? #2099
Answered
by
jackc
DanielCoder834
asked this question in
Q&A
-
I found this documentation on how the sql library prevents SQL injection. Does the pgx have something similar to the method they introduce? Thank you for any help on the matter. |
Beta Was this translation helpful? Give feedback.
Answered by
jackc
Aug 3, 2024
Replies: 1 comment 3 replies
-
Yes, if you are using $1, $2, etc. then SQL injection is prevented. pgx uses the PostgreSQL extended protocol / prepared statements by default where the SQL string and the arguments are passed separately to the PostgreSQL database. When using the simple protocol, pgx handles variable sanitization and interpolation. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
DanielCoder834
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, if you are using $1, $2, etc. then SQL injection is prevented. pgx uses the PostgreSQL extended protocol / prepared statements by default where the SQL string and the arguments are passed separately to the PostgreSQL database. When using the simple protocol, pgx handles variable sanitization and interpolation.