Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Internal
--------
* Refine documentation for Windows.
* Target Python 3.10 for linting.
* Use fully-qualified pymysql exception classes.


1.42.0 (2025/12/20)
Expand Down
12 changes: 6 additions & 6 deletions mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from prompt_toolkit.layout.processors import ConditionalProcessor, HighlightMatchingBracketProcessor
from prompt_toolkit.lexers import PygmentsLexer
from prompt_toolkit.shortcuts import CompleteStyle, PromptSession
from pymysql import OperationalError, err
import pymysql
from pymysql.cursors import Cursor
import sqlglot
import sqlparse
Expand Down Expand Up @@ -532,7 +532,7 @@ def _connect() -> None:
ssh_key_filename,
init_command,
)
except OperationalError as e:
except pymysql.OperationalError as e:
if e.args[0] == ERROR_CODE_ACCESS_DENIED:
if password_from_file is not None:
new_passwd = password_from_file
Expand Down Expand Up @@ -566,7 +566,7 @@ def _connect() -> None:
self.echo(f"Connecting to socket {socket}, owned by user {socket_owner}", err=True)
try:
_connect()
except OperationalError as e:
except pymysql.OperationalError as e:
# These are "Can't open socket" and 2x "Can't connect"
if [code for code in (2001, 2002, 2003) if code == e.args[0]]:
self.logger.debug("Database connection failed: %r.", e)
Expand Down Expand Up @@ -919,7 +919,7 @@ def one_iteration(text: str | None = None) -> None:
output_res(res, start)
special.unset_once_if_written(self.post_redirect_command)
special.flush_pipe_once_if_written(self.post_redirect_command)
except err.InterfaceError:
except pymysql.err.InterfaceError:
# attempt to reconnect
if not self.reconnect():
return
Expand Down Expand Up @@ -955,7 +955,7 @@ def one_iteration(text: str | None = None) -> None:
self.echo("Did not get a connection id, skip cancelling query", err=True, fg="red")
except NotImplementedError:
self.echo("Not Yet Implemented.", fg="yellow")
except OperationalError as e1:
except pymysql.OperationalError as e1:
logger.debug("Exception: %r", e1)
if e1.args[0] in (2003, 2006, 2013):
# attempt to reconnect
Expand Down Expand Up @@ -1044,7 +1044,7 @@ def reconnect(self, database: str = "") -> bool:
self.echo("Reconnecting...", fg="yellow")
try:
self.sqlexecute.connect()
except OperationalError as e:
except pymysql.OperationalError as e:
self.logger.debug("Reconnect failed. e: %r", e)
self.echo(str(e), err=True, fg="red")
return False
Expand Down