Skip to main content

Parse database connection strings

Project description


Parse database connection strings in python. Currently only supports MySQL.

>>> import cxnstr
>>> params = cxnstr.to_dict("myhost:3306/MyDB?read_default_file=~/.my.cnf")
>>> params
{'host': 'myhost', 'port': 3306, 'db': 'MyDB', 'read_default_file': '~/.my.cnf'}
>>> import pymysql
>>> conn = pymysql.connect(**params)

See doctests for full connection string specification.

The library also includes a command line program for parsing connection strings and outputting in various formats:

$ cxnstr -t json "myhost:3306/MyDB?read_default_file=~/.my.cnf"
{"read_default_file": "~/.my.cnf", "db": "MyDB", "host": "myhost", "port": 3306}

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cxnstr, version 1.1.4
Filename, size File type Python version Upload date Hashes
Filename, size cxnstr-1.1.4-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cxnstr-1.1.4.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page