Skip to content

Commit

Permalink
Adding support for vertica database URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Shaw committed Nov 14, 2019
1 parent 293c329 commit 2af10c2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 41 deletions.
70 changes: 36 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,40 +98,41 @@ The following are example database connection URLs that can be handled by
The following protocols schemes (ie, driver) and their associated aliases are
supported out of the box:

| Database (scheme/driver) | Protocol Aliases [real driver] |
|------------------------------|-------------------------------------------|
| Microsoft SQL Server (mssql) | ms, sqlserver |
| MySQL (mysql) | my, mariadb, maria, percona, aurora |
| Oracle Database (goracle) | or, ora, oracle, oci, oci8, odpi, odpi-c |
| PostgreSQL (postgres) | pg, postgresql, pgsql |
| SQLite3 (sqlite3) | sq, sqlite, file |
| | |
| Amazon Redshift (redshift) | rs [postgres] |
| CockroachDB (cockroachdb) | cr, cockroach, crdb, cdb [postgres] |
| MemSQL (memsql) | me [mysql] |
| TiDB (tidb) | ti [mysql] |
| Vitess (vitess) | vt [mysql] |
| | |
| Google Spanner (spanner) | gs, google, span (not yet public) |
| | |
| MySQL (mymysql) | zm, mymy |
| PostgreSQL (pgx) | px |
| | |
| Apache Avatica (avatica) | av, phoenix |
| Apache Ignite (ignite) | ig, gridgain |
| Cassandra (cql) | ca, cassandra, datastax, scy, scylla |
| ClickHouse (clickhouse) | ch |
| Couchbase (n1ql) | n1, couchbase |
| Cznic QL (ql) | ql, cznic, cznicql |
| Firebird SQL (firebirdsql) | fb, firebird |
| Microsoft ADODB (adodb) | ad, ado |
| ODBC (odbc) | od |
| OLE ODBC (oleodbc) | oo, ole, oleodbc [adodb] |
| Presto (presto) | pr, prestodb, prestos, prs, prestodbs |
| SAP ASE (tds) | ax, ase, sapase |
| SAP HANA (hdb) | sa, saphana, sap, hana |
| Snowflake (snowflake) | sf |
| VoltDB (voltdb) | vo, volt, vdb |
| Database (scheme/driver) | Protocol Aliases [real driver] |
|------------------------------|------------------------------------------|
| Microsoft SQL Server (mssql) | ms, sqlserver |
| MySQL (mysql) | my, mariadb, maria, percona, aurora |
| Oracle Database (goracle) | or, ora, oracle, oci, oci8, odpi, odpi-c |
| PostgreSQL (postgres) | pg, postgresql, pgsql |
| SQLite3 (sqlite3) | sq, sqlite, file |
| | |
| Amazon Redshift (redshift) | rs [postgres] |
| CockroachDB (cockroachdb) | cr, cockroach, crdb, cdb [postgres] |
| MemSQL (memsql) | me [mysql] |
| TiDB (tidb) | ti [mysql] |
| Vitess (vitess) | vt [mysql] |
| | |
| Google Spanner (spanner) | gs, google, span (not yet public) |
| | |
| MySQL (mymysql) | zm, mymy |
| PostgreSQL (pgx) | px |
| | |
| Apache Avatica (avatica) | av, phoenix |
| Apache Ignite (ignite) | ig, gridgain |
| Cassandra (cql) | ca, cassandra, datastax, scy, scylla |
| ClickHouse (clickhouse) | ch |
| Couchbase (n1ql) | n1, couchbase |
| Cznic QL (ql) | ql, cznic, cznicql |
| Firebird SQL (firebirdsql) | fb, firebird |
| Microsoft ADODB (adodb) | ad, ado |
| ODBC (odbc) | od |
| OLE ODBC (oleodbc) | oo, ole, oleodbc [adodb] |
| Presto (presto) | pr, prestodb, prestos, prs, prestodbs |
| SAP ASE (tds) | ax, ase, sapase |
| SAP HANA (hdb) | sa, saphana, sap, hana |
| Snowflake (snowflake) | sf |
| Vertica (vertica) | ve |
| VoltDB (voltdb) | vo, volt, vdb |

Any protocol scheme `alias://` can be used in place of `protocol://`, and will
work identically with [`dburl.Parse`][godoc-parse] and [`dburl.Open`][godoc-open].
Expand Down Expand Up @@ -186,6 +187,7 @@ to be imported:
| SAP ASE (tds) | [github.com/thda/tds](https://github.com/thda/tds) |
| SAP HANA (hdb) | [github.com/SAP/go-hdb/driver](https://github.com/SAP/go-hdb) |
| Snowflake (snowflake) | [github.com/snowflakedb/gosnowflake](https://github.com/snowflakedb/gosnowflake) |
| Vertica (vertica) | [github.com/vertica/vertica-sql-go](https://github.com/vertica/vertica-sql-go) |
| VoltDB (voltdb) | [github.com/VoltDB/voltdb-client-go/voltdbclient](github.com/VoltDB/voltdb-client-go]) |

Please see [the `dburl` GoDoc listing][godoc-link] for the full API
Expand Down
2 changes: 2 additions & 0 deletions dburl.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
// SAP ASE (tds) | ax, ase, sapase
// SAP HANA (hdb) | sa, saphana, sap, hana
// Snowflake (snowflake) | sf
// Vertica (vertica) | ve
// VoltDB (voltdb) | vo, volt, vdb
//
// Any protocol scheme alias:// can be used in place of protocol://, and will
Expand Down Expand Up @@ -148,6 +149,7 @@
// SAP ASE (tds) | github.com/thda/tds
// SAP HANA (hdb) | github.com/SAP/go-hdb/driver
// Snowflake (snowflake) | github.com/snowflakedb/gosnowflake
// Vertica (vertica) | github.com/vertica/vertica-sql-go
// VoltDB (voltdb) | github.com/VoltDB/voltdb-client-go/voltdbclient
//
// * OLE ODBC is a special alias for using the "MSDASQL.1" OLE provider with the
Expand Down
20 changes: 14 additions & 6 deletions dburl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,18 @@ func TestParse(t *testing.T) {
{`mssql://user@localhost/service/dbname`, `mssql`, `Database=dbname;Server=localhost\service;User ID=user`, ``},
{`mssql://user:!234%23$@localhost:1580/dbname`, `mssql`, `Database=dbname;Password=!234#$;Port=1580;Server=localhost;User ID=user`, ``},

{`adodb://Microsoft.ACE.OLEDB.12.0?Extended+Properties=%22Text%3BHDR%3DNO%3BFMT%3DDelimited%22`, `adodb`, // 30
`Data Source=.;Extended Properties="Text;HDR=NO;FMT=Delimited";Provider=Microsoft.ACE.OLEDB.12.0`, ``},
{`adodb://user:pass@Provider.Name:1542/Oracle8i/dbname`, `adodb`,
`Data Source=Oracle8i;Database=dbname;Password=pass;Port=1542;Provider=Provider.Name;User ID=user`, ``},
{`oo+Postgres+Unicode://user:pass@host:5432/dbname`, `adodb`,
`Provider=MSDASQL.1;Extended Properties="Database=dbname;Driver={Postgres Unicode};PWD=pass;Port=5432;Server=host;UID=user"`, ``},
{
`adodb://Microsoft.ACE.OLEDB.12.0?Extended+Properties=%22Text%3BHDR%3DNO%3BFMT%3DDelimited%22`, `adodb`, // 30
`Data Source=.;Extended Properties="Text;HDR=NO;FMT=Delimited";Provider=Microsoft.ACE.OLEDB.12.0`, ``,
},
{
`adodb://user:pass@Provider.Name:1542/Oracle8i/dbname`, `adodb`,
`Data Source=Oracle8i;Database=dbname;Password=pass;Port=1542;Provider=Provider.Name;User ID=user`, ``,
},
{
`oo+Postgres+Unicode://user:pass@host:5432/dbname`, `adodb`,
`Provider=MSDASQL.1;Extended Properties="Database=dbname;Driver={Postgres Unicode};PWD=pass;Port=5432;Server=host;UID=user"`, ``,
},

{`file:/path/to/file.sqlite3`, `sqlite3`, `/path/to/file.sqlite3`, ``}, // 33
{`sqlite:///path/to/file.sqlite3`, `sqlite3`, `/path/to/file.sqlite3`, ``},
Expand Down Expand Up @@ -149,6 +155,8 @@ func TestParse(t *testing.T) {
{`sf://user:pass@localhost:9999/dbname/schema?timeout=1000`, `snowflake`, `user:pass@localhost:9999/dbname/schema?timeout=1000`, ``},

{`rs://user:pass@amazon.com/dbname`, `postgres`, `postgres://user:pass@amazon.com:5439/dbname`, ``}, // 68

{`ve://user:pass@vertica-host/dbvertica?tlsmode=server-strict`, `vertica`, `vertica://user:pass@vertica-host:5433/dbvertica?tlsmode=server-strict`, ``}, // 69
}

for i, test := range tests {
Expand Down
3 changes: 2 additions & 1 deletion scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func BaseSchemes() []Scheme {
// other databases
{"adodb", GenADODB, 0, false, []string{"ado"}, ""},
{"avatica", GenFromURL("http://localhost:8765/"), 0, false, []string{"phoenix"}, ""},
{"cql", GenCassandra, 0, false, []string{"ca", "cassandra", "datastax", "scy", "scylla"}, ""},
{"clickhouse", GenClickhouse, 0, false, []string{"ch"}, ""},
{"cql", GenCassandra, 0, false, []string{"ca", "cassandra", "datastax", "scy", "scylla"}, ""},
{"firebirdsql", GenFirebird, 0, false, []string{"fb", "firebird"}, ""},
{"hdb", GenScheme("hdb"), 0, false, []string{"sa", "saphana", "sap", "hana"}, ""},
{"ignite", GenIgnite, 0, false, []string{"ig", "gridgain"}, ""},
Expand All @@ -87,6 +87,7 @@ func BaseSchemes() []Scheme {
{"ql", GenOpaque, 0, true, []string{"ql", "cznic", "cznicql"}, ""},
{"snowflake", GenSnowflake, 0, false, []string{"sf"}, ""},
{"tds", GenFromURL("http://localhost:5000/"), 0, false, []string{"ax", "ase", "sapase"}, ""},
{"vertica", GenFromURL("vertica://localhost:5433/"), 0, false, nil, ""},
{"voltdb", GenVoltDB, 0, false, []string{"volt", "vdb"}, ""},
}
}
Expand Down

0 comments on commit 2af10c2

Please sign in to comment.