MCPcopy Index your code
hub / github.com/dbcli/mycli / is_destructive

Function is_destructive

mycli/packages/sql_utils.py:386–400  ·  view source on GitHub ↗

Returns True if any of the queries in *queries* is destructive.

(keywords: list[str], queries: str)

Source from the content-addressed store, hash-verified

384
385
386def is_destructive(keywords: list[str], queries: str) -> bool:
387 """Returns True if any of the queries in *queries* is destructive."""
388 for query in sqlparse.split(queries):
389 if not query:
390 continue
391 # subtle: if "UPDATE" is one of our keywords AND "query" starts with "UPDATE"
392 if query_starts_with(query, keywords) and query_starts_with(query, ["update"]):
393 if query_has_where_clause(query) and query_is_single_table_update(query):
394 return False
395 else:
396 return True
397 if query_starts_with(query, keywords):
398 return True
399
400 return False
401
402
403def is_dropping_database(queries: str, dbname: str | None) -> bool:

Calls 4

query_starts_withFunction · 0.85
query_has_where_clauseFunction · 0.85
splitMethod · 0.80