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
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Upcoming (TBD)
==============

Breaking Changes
--------
* Remove support for deprecated environment variable `$DSN`.


1.75.0 (2026/06/20)
==============

Expand Down
10 changes: 0 additions & 10 deletions mycli/cli_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,6 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non
if not cli_args.socket:
cli_args.socket = os.environ['MYSQL_UNIX_PORT']

if 'DSN' in os.environ:
# deprecated 2026-03
click.secho(
"The DSN environment variable is deprecated in favor of MYSQL_DSN. Support for DSN will be removed in a future release.",
err=True,
fg="red",
)
if not cli_args.dsn:
cli_args.dsn = os.environ['DSN']

# Choose which ever one has a valid value.
database = cli_args.dbname or cli_args.database

Expand Down
53 changes: 0 additions & 53 deletions test/pytests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,59 +1285,6 @@ def run_query(self, query, new_line=True):
)


def test_legacy_dsn_envvar_warns_and_falls_back(monkeypatch):
class Formatter:
format_name = None

class Logger:
def debug(self, *args, **args_dict):
pass

def warning(self, *args, **args_dict):
pass

class MockMyCli:
config = {
'main': {},
'alias_dsn': {},
'connection': {
'default_keepalive_ticks': 0,
},
}

def __init__(self, **_args):
self.logger = Logger()
self.destructive_warning = False
self.main_formatter = Formatter()
self.redirect_formatter = Formatter()
self.ssl_mode = 'auto'
self.my_cnf = {'client': {}, 'mysqld': {}}
self.default_keepalive_ticks = 0

def connect(self, **args):
MockMyCli.connect_args = args

def run_query(self, query, new_line=True):
pass

import mycli.main

monkeypatch.setattr(mycli.main, 'MyCli', MockMyCli)
monkeypatch.setenv('DSN', 'mysql://dsn_user:dsn_passwd@dsn_host:8/dsn_database')
runner = CliRunner()

result = runner.invoke(mycli.main.click_entrypoint)
assert result.exit_code == 0, result.output + ' ' + str(result.exception)
assert 'The DSN environment variable is deprecated' in result.output
assert (
MockMyCli.connect_args['user'] == 'dsn_user'
and MockMyCli.connect_args['passwd'] == 'dsn_passwd'
and MockMyCli.connect_args['host'] == 'dsn_host'
and MockMyCli.connect_args['port'] == 8
and MockMyCli.connect_args['database'] == 'dsn_database'
)


def test_password_flag_uses_sentinel(monkeypatch):
class Formatter:
format_name = None
Expand Down
Loading