Skip to content

Commit 2df5307

Browse files
authored
Merge pull request #1946 from dbcli/RW/remove-dsn-env-variable-support
Remove support for deprecated `$DSN` environment variable
2 parents af7c2ab + 7de6848 commit 2df5307

3 files changed

Lines changed: 1 addition & 64 deletions

File tree

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Upcoming (TBD)
22
==============
33

44
Breaking Changes
5-
---------
65
* Change default table format to `mysql_unicode`.
6+
* Remove support for deprecated environment variable `$DSN`.
77

88

99
Internal

mycli/cli_runner.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,6 @@ def run_from_cli_args(cli_args: 'CliArgs', client_factory: ClientFactory) -> Non
178178
if not cli_args.socket:
179179
cli_args.socket = os.environ['MYSQL_UNIX_PORT']
180180

181-
if 'DSN' in os.environ:
182-
# deprecated 2026-03
183-
click.secho(
184-
"The DSN environment variable is deprecated in favor of MYSQL_DSN. Support for DSN will be removed in a future release.",
185-
err=True,
186-
fg="red",
187-
)
188-
if not cli_args.dsn:
189-
cli_args.dsn = os.environ['DSN']
190-
191181
# Choose which ever one has a valid value.
192182
database = cli_args.dbname or cli_args.database
193183

test/pytests/test_main.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,59 +1285,6 @@ def run_query(self, query, new_line=True):
12851285
)
12861286

12871287

1288-
def test_legacy_dsn_envvar_warns_and_falls_back(monkeypatch):
1289-
class Formatter:
1290-
format_name = None
1291-
1292-
class Logger:
1293-
def debug(self, *args, **args_dict):
1294-
pass
1295-
1296-
def warning(self, *args, **args_dict):
1297-
pass
1298-
1299-
class MockMyCli:
1300-
config = {
1301-
'main': {},
1302-
'alias_dsn': {},
1303-
'connection': {
1304-
'default_keepalive_ticks': 0,
1305-
},
1306-
}
1307-
1308-
def __init__(self, **_args):
1309-
self.logger = Logger()
1310-
self.destructive_warning = False
1311-
self.main_formatter = Formatter()
1312-
self.redirect_formatter = Formatter()
1313-
self.ssl_mode = 'auto'
1314-
self.my_cnf = {'client': {}, 'mysqld': {}}
1315-
self.default_keepalive_ticks = 0
1316-
1317-
def connect(self, **args):
1318-
MockMyCli.connect_args = args
1319-
1320-
def run_query(self, query, new_line=True):
1321-
pass
1322-
1323-
import mycli.main
1324-
1325-
monkeypatch.setattr(mycli.main, 'MyCli', MockMyCli)
1326-
monkeypatch.setenv('DSN', 'mysql://dsn_user:dsn_passwd@dsn_host:8/dsn_database')
1327-
runner = CliRunner()
1328-
1329-
result = runner.invoke(mycli.main.click_entrypoint)
1330-
assert result.exit_code == 0, result.output + ' ' + str(result.exception)
1331-
assert 'The DSN environment variable is deprecated' in result.output
1332-
assert (
1333-
MockMyCli.connect_args['user'] == 'dsn_user'
1334-
and MockMyCli.connect_args['passwd'] == 'dsn_passwd'
1335-
and MockMyCli.connect_args['host'] == 'dsn_host'
1336-
and MockMyCli.connect_args['port'] == 8
1337-
and MockMyCli.connect_args['database'] == 'dsn_database'
1338-
)
1339-
1340-
13411288
def test_password_flag_uses_sentinel(monkeypatch):
13421289
class Formatter:
13431290
format_name = None

0 commit comments

Comments
 (0)