Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion index.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,21 @@

def get_data_by_config_value(value):
# This might look suspicious due to string concatenation with values from CONFIG.
query = "SELECT * FROM " + CONFIG["default_table"] + " WHERE " + CONFIG["default_column"] + " = '" + value + "'"
"""Retrieves data from a database based on a specified configuration value.

Args:
value (str): The value to match in the database query.

Returns:
list: A list of tuples containing the query results.

Raises:
sqlite3.Error: If there is an issue with the database connection or query execution.

Note:
This method uses string concatenation to build the SQL query, which may be vulnerable
to SQL injection attacks. It is recommended to use parameterized queries instead.
""" query = "SELECT * FROM " + CONFIG["default_table"] + " WHERE " + CONFIG["default_column"] + " = '" + value + "'"

connection = sqlite3.connect("database.db")
cursor = connection.cursor()
Expand Down