Skip to content
Advertisement

Tag: sql

How to avoid SQL injection on query

My SQL query construction in python code is: When I run Bandit security tool, it says “Possible SQL injection vector through string-based query construction.” How do I avoid it? Answer Best practices recommend to avoid to dynamically build the query and instead use a parameterized query. But the goal is precisely to avoid what you are doing here: prevent a

Why does the id serial primary key keep changing?

I have just started a full stack web developer course which includes PostgreSQL. I have been give some practice questions to do and when I clicked on run SQL it displays the id, first_name and last_name but when I entered in more lines of code to answer more questions and clicked on run SQL again, the id number changed to

Input parameters in procedure

Tell me how to solve such a case: There is a predicate in the stored procedure that searches for input_param by the input parameter: When calling this procedure, I need to pass two or much parameters: It naturally doesn’t work Are there any solutions? Answer Would this help? Sample data: Procedure:

Append Row To Each Group in SQL

Let’s say that I have database table: Following: I get: However, for each group, I’d like to append an additional row with the value column taken from the id column so that the resulting table looks like: What is ANSI SQL (or most database agnostic) way to accomplish this? Answer You don’t want a group by in the initial set

Advertisement