MCPcopy Index your code
hub / github.com/caesarHQ/textSQL / is_read_only_query

Function is_read_only_query

byod/api/app/sql_generation/utils.py:71–85  ·  view source on GitHub ↗

Checks if the given SQL query string is read-only. Returns True if the query is read-only, False otherwise.

(sql_query: str)

Source from the content-addressed store, hash-verified

69 )
70
71def is_read_only_query(sql_query: str) -> bool:
72 """
73 Checks if the given SQL query string is read-only.
74 Returns True if the query is read-only, False otherwise.
75 """
76 # List of SQL statements that modify data in the database
77 modifying_statements = ["INSERT", "UPDATE", "DELETE", "DROP", "CREATE", "ALTER", "GRANT", "TRUNCATE", "LOCK TABLES", "UNLOCK TABLES"]
78
79 # Check if the query contains any modifying statements
80 for statement in modifying_statements:
81 if statement in sql_query.upper():
82 return False
83
84 # If no modifying statements are found, the query is read-only
85 return True
86
87
88class NotReadOnlyException(Exception):

Callers 1

execute_sqlFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected