这是indexloc提供的服务,不要输入任何密码
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 @@ -14,6 +14,7 @@ Bug Fixes
* Improve handling of `ssl-verify-server-cert` False values.
* Guard against missing contributors file on startup.
* Friendlier errors on password-file failures.
* Better handle empty-string passwords.


Internal
Expand Down
11 changes: 6 additions & 5 deletions mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def connect(
self,
database: str | None = "",
user: str | None = "",
passwd: str = "",
passwd: str | None = "",
host: str | None = "",
port: str | int | None = "",
socket: str | None = "",
Expand Down Expand Up @@ -459,7 +459,8 @@ def connect(

# if the passwd is not specified try to set it using the password_file option
password_from_file = self.get_password_from_file(password_file)
passwd = passwd or password_from_file
passwd = passwd if isinstance(passwd, str) else password_from_file
passwd = '' if passwd is None else passwd

# Connect to the database.

Expand All @@ -484,7 +485,7 @@ def _connect() -> None:
)
except OperationalError as e:
if e.args[0] == ERROR_CODE_ACCESS_DENIED:
if password_from_file:
if password_from_file is not None:
new_passwd = password_from_file
else:
new_passwd = click.prompt(f"Password for {user}", hide_input=True, show_default=False, type=str, err=True)
Expand Down Expand Up @@ -549,9 +550,9 @@ def _connect() -> None:
self.echo(str(e), err=True, fg="red")
sys.exit(1)

def get_password_from_file(self, password_file: str) -> str:
def get_password_from_file(self, password_file: str) -> str | None:
if not password_file:
return ''
return None
try:
with open(password_file) as fp:
password = fp.readline().strip()
Expand Down