Skip to content

Instantly share code, notes, and snippets.

@relthyg
relthyg / mysql-dsn
Last active October 11, 2021 21:54
mysql-dsn: Connect to a mysql database from the command line using a DSN as argument
#!/usr/bin/env python3
#
# mysql-dsn
# Takes a DSN as argument and tries to connect to the specified database using the "mysql"-command.
# Passwords must be quoted ("url-encoded").
#
# Example:
# $ mysql-dsn mysqli://me:top_secret@hostname:33006/db-name
import re