MCPcopy Create free account
hub / github.com/dbcli/mycli / need_completion_reset

Function need_completion_reset

mycli/packages/sql_utils.py:454–469  ·  view source on GitHub ↗

Determines if the statement is a database switch such as 'use' or '\\u'. When a database is changed the existing completions must be reset before we start the completion refresh for the new database.

(queries: str)

Source from the content-addressed store, hash-verified

452
453
454def need_completion_reset(queries: str) -> bool:
455 """Determines if the statement is a database switch such as 'use' or '\\u'.
456 When a database is changed the existing completions must be reset before we
457 start the completion refresh for the new database.
458 """
459 for query in sqlparse.split(queries):
460 try:
461 tokens = query.split()
462 first_token = tokens[0]
463 if first_token.lower() in ("use", "/use", "\\u", "/u"):
464 return True
465 if first_token.lower() in ("\\r", "/r", "connect", "/connect") and len(tokens) > 1:
466 return True
467 except Exception:
468 continue
469 return False
470
471
472def is_mutating(status_plain: str | None) -> bool:

Calls 1

splitMethod · 0.80