Use SQLAlchemy to generate SQL queries #2

Open
opened 2026-06-25 15:36:46 +00:00 by eliribble · 0 comments
Owner

Currently the program uses various string injections. See an example:

                cur.execute(
                    "SELECT task_name, completed, COALESCE(assigned_to, 'No one') FROM task WHERE user_sub = %s",
                    (sub,),
                )

These should instead be done as SQLAlchemy queries which make it much easier to ensure that the query is well-formed. It also provides protection against injection attacks.

Currently the program uses various string injections. See [an example](https://source.gleipnir.technology/Gleipnir/mechaturk/src/branch/main/backend/app.py#L283): ``` cur.execute( "SELECT task_name, completed, COALESCE(assigned_to, 'No one') FROM task WHERE user_sub = %s", (sub,), ) ``` These should instead be done as [SQLAlchemy queries](https://docs.sqlalchemy.org/en/20/tutorial/index.html) which make it much easier to ensure that the query is well-formed. It also provides protection against injection attacks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Gleipnir/mechaturk#2
No description provided.