skip to navigation
skip to content

Not Logged In

dsnparse 0.1.3

parse dsn urls

Parse dsn connection url strings. I kept duplicating dsn parsing code for things like prom and morp, and I realized I was going to need many more dsn urls in the future so I decided to create something a little more modular.

This is a generic version of dj-database-url.

So, now you can create dsns like this:


For example, let’s look at a prom dsn:


Now let’s parse it:

import dsnparse

dsn = "prom.interface.postgres.Interface://testuser:testpw@localhost:1234/testdb"
r = dsnparse.parse(dsn)

print r.scheme # prom.interface.postgres.Interface
print r.username # testuser
print r.password # testpw
print # localhost
print r.hostloc # localhost:1234
print r.paths # ['testdb']

Also, dsnparse can easily use environment variables:

r = dsnparse.parse_environ('ENVIRONMENT_VARIABLE_NAME')

I tried to keep the interface very similar to urlparse so it will feel familiar to use.


Use pip:

pip install dsnparse

or use github:

pip install git+



File Type Py Version Uploaded on Size
dsnparse-0.1.3.tar.gz (md5) Source 2014-01-14 3KB
  • Downloads (All Versions):
  • 26 downloads in the last day
  • 73 downloads in the last week
  • 341 downloads in the last month