$ show xo/dburl
dburl is a zero-dependency Go library that parses database connection URLs in a standard URL format and converts them to the DSN strings that Go SQL drivers expect. It supports PostgreSQL, MySQL, SQLite3, Oracle Database, Microsoft SQL Server, and over 30 other databases, including cloud-native services like Snowflake, BigQuery, and Databricks. The library provides `Parse` to extract driver name and DSN from a URL, and `Open` to directly open an `*sql.DB` connection. It also includes a `passfile` subpackage for reading `.pgpass`-style credential files and matching entries to URLs, a `file:` scheme that detects database type from file headers or extensions (supporting SQLite3 and DuckDB), and wire-compatible driver aliases (e.g., CockroachDB → PostgreSQL, TiDB → MySQL). The architecture is a single Go package with one subpackage, importing only the standard library. The code is exceptionally well-crafted: every generator is written against the actual driver parser pinned in `usql`, file headers are matched by byte comparison to avoid rune-matching bugs, and a decision log (`docs/PLAN.md`) documents every design choice with rationale. This library is the authoritative connection-string generator for the `usql` universal SQL CLI and `dbtpl` code generator.
The LLM identified 1 files worth highlighting for reuse:
A self-contained subpackage for reading `.pgpass`-style password files. It parses colon-delimited entries (protocol:host:port:dbname:user:password), supports wildcard matching for host/port/protocol, and provides secure file permissions checking (rejects group/world-accessible files on Unix). The API is cleanly layered: Parse(io.Reader), ParseFile(string), Match(*dburl.URL, entries) for credential injection, and Open/OpenURL for automatic password lookup. Custom error types (FileError, InvalidEntryError, EmptyFieldError) provide structured error reporting. This component solves a common database-credential problem and could be extracted into a standalone package with minimal modification.