xo /dburl

Package dburl provides a standard, URL style mechanism for parsing and opening SQL database connection strings

★ 298⑂ 43👁 6⑃ 24● 31▤ 39
GoMITCreated 2016-05-10
下载:v0.58.0v0.58.0 ↓0.58.02026-11-08
+0
日增长
298
stars
43
forks
6
watchers
24
prs
31
issues
39
releases

README

About dburl

Package dburl [parses][goref-parse] and [opens][goref-open] SQL database
connection strings for [Go][go-project], in a standard URL style. It handles
the URL formats of PostgreSQL, MySQL, SQLite3, Oracle Database and Microsoft
SQL Server. It also handles most other SQL databases that have a public Go
driver.

[Overview][] | [Quickstart][] | [Examples][] | [Schemes][] | [Installing][] | [Using][] | [About][]

[Overview]: database-connection-url-overview "Database Connection URL Overview"
[Quickstart]: quickstart "Quickstart"
[Examples]: example-urls "Example URLs"
[Schemes]: database-schemes-aliases-and-drivers "Database Schemes, Aliases, and Drivers"
[Installing]: installing "Installing"
[Using]: using "Using"
[About]: about "About"

[![Unit Tests][dburl-ci-status]][dburl-ci]
[![Go Reference][goref-dburl-status]][goref-dburl]
[![Discord Discussion][discord-status]][discord]

[dburl-ci]: https://github.com/xo/dburl/actions/workflows/test.yml
[dburl-ci-status]: https://github.com/xo/dburl/actions/workflows/test.yml/badge.svg
[goref-dburl]: https://pkg.go.dev/github.com/xo/dburl
[goref-dburl-status]: https://pkg.go.dev/badge/github.com/xo/dburl.svg
[discord]: https://discord.gg/yJKEzc7prt "Discord Discussion"
[discord-status]: https://img.shields.io/discord/829150509658013727.svg?label=Discord&logo=Discord&colorB=7289da&style=flat-square "Discord Discussion"

 Database Connection URL Overview

Supported database connection URLs are of the form:

text
protocol+transport://user:pass@host/dbname?opt1=a&opt2=b
protocol:/path/to/file


Where:

| Component           | Description                                                                          |
| ------------------- | ------------------------------------------------------------------------------------ |
| protocol            | driver name or alias (see below)                                                     |
| transport           | "tcp", "udp", "unix", "http", "https", or a driver name for odbc                     |
| user                | username                                                                             |
| pass                | password                                                                             |
| host                | host                                                                                 |
| dbname\ | database, instance, or service name to connect to                                    |
| ?opt1=...           | additional database driver options (see respective SQL driver for available options) |

\ For Microsoft SQL Server, /dbname can be
/instance/dbname, where /instance is optional. For Oracle Database,
/dbname takes the form /service/instance, where /instance is optional.
Write a / that is part of a service name as %2F. See the examples below.

 Quickstart

The [dburl.Parse func][goref-parse] parses a database connection URL in the
format above:

go
import (
    "github.com/xo/dburl"
)

u, err := dburl.Parse("postgresql://

Latest release

v0.58.0 v0.58.0 2026-11-08
Moves the hive and impala schemes to the dbimp driver github.com/xo/dbimp/hive. Both write hive://user:password@host:port/database?httpPath=.... The auth=NONE and default database defaults are gone, and impala adds port 28000. Provisional until dbimp tags the driver (D74).

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON