diff options
author | Georgy Frolov <gosha@fro.lv> | 2021-02-23 15:31:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-23 15:31:24 +0300 |
commit | 4ac38ecf359a1d0738dc2b5919af701387aef62b (patch) | |
tree | cba473286165531a7626ea0b52a651e65032b3bf | |
parent | bbbbb0d2128e76cad156a13c9631c7a8fab93868 (diff) |
Check error code, not message for OperationalError (#964)
* Check error code, not message for OperationalError
* changelog
* merge fix
-rw-r--r-- | changelog.md | 1 | ||||
-rwxr-xr-x | mycli/main.py | 4 | ||||
-rw-r--r-- | mycli/sqlexecute.py | 3 |
3 files changed, 6 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md index 42bbb8a..0173322 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ Bug Fixes: ---------- * Allow `FileNotFound` exception for SSH config files. * Fix startup error on MySQL < 5.0.22 +* Check error code rather than message for Access Denied error Features: --------- diff --git a/mycli/main.py b/mycli/main.py index feaa78c..63135a5 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -43,7 +43,7 @@ from .packages.special.favoritequeries import FavoriteQueries from .sqlcompleter import SQLCompleter from .clitoolbar import create_toolbar_tokens_func from .clistyle import style_factory, style_factory_output -from .sqlexecute import FIELD_TYPES, SQLExecute +from .sqlexecute import FIELD_TYPES, SQLExecute, ERROR_CODE_ACCESS_DENIED from .clibuffer import cli_is_multiline from .completion_refresher import CompletionRefresher from .config import (write_default_config, get_mylogin_cnf_path, @@ -432,7 +432,7 @@ class MyCli(object): ssh_password, ssh_key_filename, init_command ) except OperationalError as e: - if ('Access denied for user' in e.args[1]): + if e.args[0] == ERROR_CODE_ACCESS_DENIED: new_passwd = click.prompt('Password', hide_input=True, show_default=False, type=str, err=True) self.sqlexecute = SQLExecute( diff --git a/mycli/sqlexecute.py b/mycli/sqlexecute.py index ed7d2f0..9461438 100644 --- a/mycli/sqlexecute.py +++ b/mycli/sqlexecute.py @@ -21,6 +21,9 @@ FIELD_TYPES.update({ }) +ERROR_CODE_ACCESS_DENIED = 1045 + + class ServerSpecies(enum.Enum): MySQL = 'MySQL' MariaDB = 'MariaDB' |