We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5e38558 commit 0ad3d47Copy full SHA for 0ad3d47
index.py
@@ -7,12 +7,12 @@
7
}
8
9
def get_data_by_config_value(value):
10
- # This might look suspicious due to string concatenation with values from CONFIG.
11
- query = "SELECT * FROM " + CONFIG["default_table"] + " WHERE " + CONFIG["default_column"] + " = '" + value + "'"
+ # Use predefined CONFIG values and a parameterized query for protection against SQL Injection
+ query = f"SELECT * FROM {CONFIG['default_table']} WHERE {CONFIG['default_column']} = ?"
12
13
connection = sqlite3.connect("database.db")
14
cursor = connection.cursor()
15
- cursor.execute(query)
+ cursor.execute(query, (value,))
16
result = cursor.fetchall()
17
connection.close()
18
0 commit comments