|
90 | 90 | from mycli.main_modes.list_dsn import main_list_dsn |
91 | 91 | from mycli.main_modes.list_ssh_config import main_list_ssh_config |
92 | 92 | from mycli.packages import special |
| 93 | +from mycli.packages.cli_utils import is_valid_connection_scheme |
93 | 94 | from mycli.packages.filepaths import dir_path_exists, guess_socket_location |
94 | 95 | from mycli.packages.hybrid_redirection import get_redirect_components, is_redirect_command |
95 | | -from mycli.packages.parseutils import is_dropping_database, is_valid_connection_scheme |
96 | 96 | from mycli.packages.prompt_utils import confirm, confirm_destructive_query |
97 | 97 | from mycli.packages.ptoolkit.history import FileHistoryWithTimestamp |
98 | 98 | from mycli.packages.special.favoritequeries import FavoriteQueries |
99 | 99 | from mycli.packages.special.main import ArgType |
100 | 100 | from mycli.packages.special.utils import format_uptime, get_ssl_version, get_uptime, get_warning_count |
| 101 | +from mycli.packages.sql_utils import ( |
| 102 | + is_dropping_database, |
| 103 | + is_mutating, |
| 104 | + is_select, |
| 105 | + need_completion_refresh, |
| 106 | + need_completion_reset, |
| 107 | +) |
101 | 108 | from mycli.packages.sqlresult import SQLResult |
102 | 109 | from mycli.packages.ssh_utils import read_ssh_config |
103 | 110 | from mycli.packages.string_utils import sanitize_terminal_title |
@@ -2650,53 +2657,6 @@ def get_password_from_file(password_file: str | None) -> str | None: |
2650 | 2657 | mycli.close() |
2651 | 2658 |
|
2652 | 2659 |
|
2653 | | -def need_completion_refresh(queries: str) -> bool: |
2654 | | - """Determines if the completion needs a refresh by checking if the sql |
2655 | | - statement is an alter, create, drop or change db.""" |
2656 | | - for query in sqlparse.split(queries): |
2657 | | - try: |
2658 | | - first_token = query.split()[0] |
2659 | | - if first_token.lower() in ("alter", "create", "use", "\\r", "\\u", "connect", "drop", "rename"): |
2660 | | - return True |
2661 | | - except Exception: |
2662 | | - continue |
2663 | | - return False |
2664 | | - |
2665 | | - |
2666 | | -def need_completion_reset(queries: str) -> bool: |
2667 | | - """Determines if the statement is a database switch such as 'use' or '\\u'. |
2668 | | - When a database is changed the existing completions must be reset before we |
2669 | | - start the completion refresh for the new database. |
2670 | | - """ |
2671 | | - for query in sqlparse.split(queries): |
2672 | | - try: |
2673 | | - tokens = query.split() |
2674 | | - first_token = tokens[0] |
2675 | | - if first_token.lower() in ("use", "\\u"): |
2676 | | - return True |
2677 | | - if first_token.lower() in ("\\r", "connect") and len(tokens) > 1: |
2678 | | - return True |
2679 | | - except Exception: |
2680 | | - continue |
2681 | | - return False |
2682 | | - |
2683 | | - |
2684 | | -def is_mutating(status_plain: str | None) -> bool: |
2685 | | - """Determines if the statement is mutating based on the status.""" |
2686 | | - if not status_plain: |
2687 | | - return False |
2688 | | - |
2689 | | - mutating = {"insert", "update", "delete", "alter", "create", "drop", "replace", "truncate", "load", "rename"} |
2690 | | - return status_plain.split(None, 1)[0].lower() in mutating |
2691 | | - |
2692 | | - |
2693 | | -def is_select(status_plain: str | None) -> bool: |
2694 | | - """Returns true if the first word in status is 'select'.""" |
2695 | | - if not status_plain: |
2696 | | - return False |
2697 | | - return status_plain.split(None, 1)[0].lower() == "select" |
2698 | | - |
2699 | | - |
2700 | 2660 | def thanks_picker() -> str: |
2701 | 2661 | import mycli |
2702 | 2662 |
|
|
0 commit comments