Skip to content
Open
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 @@ -6,6 +6,7 @@ Features
* Let the `--dsn` argument accept literal DSNs as well as aliases.
* Accept `--character-set` as an alias for `--charset` at the CLI.
* Add SSL/TLS version to `status` output.
* Accept `socket` as a DSN query parameter.


Bug Fixes
Expand Down
2 changes: 2 additions & 0 deletions mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1993,6 +1993,8 @@ def get_password_from_file(password_file: str | None) -> str | None:
if params := dsn_params.get('ssl_verify_server_cert'):
ssl_verify_server_cert = ssl_verify_server_cert or (params[0].lower() == 'true')
ssl_enable = True
if params := dsn_params.get('socket'):
socket = socket or params[0]

ssl_mode = ssl_mode or mycli.ssl_mode # cli option or config option

Expand Down
14 changes: 14 additions & 0 deletions test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,20 @@ def run_query(self, query, new_line=True):
and MockMyCli.connect_args['database'] == 'dsn_database'
)

# accept socket as a query parameter
result = runner.invoke(
mycli.main.cli,
args=[
'mysql://dsn_user:dsn_passwd@localhost/dsn_database?socket=mysql.sock',
],
)
assert result.exit_code == 0, result.output + ' ' + str(result.exception)
assert MockMyCli.connect_args['user'] == 'dsn_user'
assert MockMyCli.connect_args['passwd'] == 'dsn_passwd'
assert MockMyCli.connect_args['host'] == 'localhost'
assert MockMyCli.connect_args['database'] == 'dsn_database'
assert MockMyCli.connect_args['socket'] == 'mysql.sock'


def test_ssh_config(monkeypatch):
# Setup classes to mock mycli.main.MyCli
Expand Down