I know that the params
parameter is the more sanitized solution to avoid SQL injections in pandas.read_sql
, but I am still not sure if it is safe to let a random user input raw data inside a SQL in the function.
For example, let the below function avaiable for an unknown user who can pass a list with the clients_ids
:
def sql_client(connection, clients_ids):
df = pd.read_sql(f"select * from clients where clients_ids in {tuple(clients_ids)}",
connection)
return df
Is this function safe from SQL injections?