dsnparse
parse dsn urls
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 dsnparseuv
uv add dsnparsepoetry
poetry add dsnparseInstalling 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
Tags
More Internet packages
Botocore provides low-level, data-driven access…
permissive · top 100 on PyPI
aiobotocoreProvides an async client for AWS services using…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
googleapis-common-protosProvides common Protocol Buffer message…
permissive · top 100 on PyPI
dj-database-urlParses DATABASE_URL environment variables into…
permissive · top 5,000 on PyPI
urlpathURLPath extends pathlib.PurePath to treat URLs…
permissive · top 15,000 on PyPI
pyfaup-rsParses URLs into components (scheme, host,…
copyleft · top 15,000 on PyPI
url-normalizeStandardizes URLs to a canonical form by…
permissive · top 1,000 on PyPI
dj-email-urlConfigures Django email backends from…
permissive · top 15,000 on PyPI
ipython-sqlAdds SQL magic commands to IPython and Jupyter…
permissive · top 15,000 on PyPI
arcpGenerate and parse arcp (Archive and Package)…
permissive · top 15,000 on PyPI
django-cache-urlConfigures Django cache backends from…
permissive · top 15,000 on PyPI
whoisitQuery RDAP (Registration Data Access Protocol)…
unclear · top 15,000 on PyPI
Redis-Sentinel-UrlParses redis:// and redis+sentinel:// URLs and…
permissive · top 15,000 on PyPI