MCPcopy Create free account
hub / github.com/caesarHQ/textSQL / is_read_only_query

Function is_read_only_query

api/app/api/utils/sql_gen/sql_helper.py:100–114  ·  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

98
99
100def is_read_only_query(sql_query: str):
101 """
102 Checks if the given SQL query string is read-only.
103 Returns True if the query is read-only, False otherwise.
104 """
105 # List of SQL statements that modify data in the database
106 modifying_statements = ["INSERT", "UPDATE", "DELETE", "DROP", "CREATE", "ALTER", "GRANT", "TRUNCATE", "LOCK TABLES", "UNLOCK TABLES"]
107
108 # Check if the query contains any modifying statements
109 for statement in modifying_statements:
110 if not sql_query or statement in sql_query.upper():
111 return False
112
113 # If no modifying statements are found, the query is read-only
114 return True

Callers 1

execute_sqlFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected