skillfed

dsnparse

parse dsn urls

dsnparse v0.4.0 547.5K downloads/30d#6,068 on PyPI21
Permissive license MIT AGING released

What it is and what it does

dsnparse is a lightweight URL parser specialized for DSN (Data Source Name) connection strings. It breaks down a DSN like `scheme://user:pass@host:port/path?query=val#fragment` into its constituent parts—scheme, username, password, host, port, paths, and query parameters—similar to Python's standard `urllib.parse.urlparse` but tailored for database and service connection URLs. The package supports custom result classes, allowing you to extend parsed results with domain-specific properties, and can read DSN values from environment variables.

It has no runtime dependencies and requires Python 3.10 or later. The interface is intentionally kept simple and familiar to developers who have used urlparse, making it a drop-in solution for projects that need to parse and extract configuration from connection strings without pulling in heavier frameworks.

Use it for:

  • Extract database credentials and connection details from a DSN string for establishing connections in application startup code.
  • Read and parse a DSN from an environment variable to configure database or service endpoints in containerized deployments.
  • Build custom result objects that extend parsed DSN data with application-specific properties or validation logic.
  • Parse non-standard or custom scheme DSNs (e.g., `prom.interface.postgres.Interface://...`) for plugin-based architectures.
  • Normalize and validate connection strings across different environments by decomposing them into individual components.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses DSN (Data Source Name) connection URL strings into structured components like scheme, username, password, host, port, and paths.

Yes, if you need to parse DSN or connection URL strings. It is lightweight, has no dependencies, and carries a permissive MIT license. The aging maintenance status (305 days since last release) is a minor concern for a stable, narrow-scope utility, but the lack of recent vulnerabilities and active repository suggest it remains reliable for its intended purpose.

Install

dsnparse on PyPI

pip

pip install dsnparse

uv

uv add dsnparse

poetry

poetry add dsnparse

Installing dsnparse

Before you install

Low install friction with no runtime dependencies. Maintenance status is aging—last release was 305 days ago, though the repository remains active and the package is marked Production/Stable.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal restrictions, making it safe for both open-source and commercial projects.

Quickstart

pip install dsnparse

import dsnparse

dsn = "prom.interface.postgres.Interface://testuser:testpw@localhost:1234/testdb"
r = dsnparse.parse(dsn)
print(r.scheme, r.username, r.host, r.port, r.paths)

Requires Python 3.10 or later.

Verify before relying

  • Whether the package handles all modern DSN formats and edge cases in real-world deployments
  • Performance characteristics when parsing very large or complex DSN strings

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 305 days since the last release
Last repo commit
First released
Downloads 547,535/month — #6,068 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: dsnparse-0.4.0-py3-none-any.whl

Keywords: dsn, url, parser, database, configuration

Development Status :: 5 - Production/StableEnvironment :: PluginsIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

dsn url parserconnection string parserdatabase url parsingparse dsn stringsconnection url componentsdatabase connection parserdsn configuration parser
url-parsingconfigurationdatabase-urls

More Internet packages