Skip to content

Commit 0376627

Browse files
committed
docs: readme CGO docs and link refresh
1 parent 8e61009 commit 0376627

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

README.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,39 +94,60 @@ So to connect to MonetDB with the binary we just built, run:
9494
Above `monetdb` is repeated in the beginning of the DB URL because it is both the Go driver name,
9595
and the admin username in the beginning of the DSN.
9696

97-
You can try the same with databases or data engines like
98-
[rqlite](https://github.com/rqlite/gorqlite),
99-
[influxdb](https://pkg.go.dev/github.com/influxdata/influxdb-iox-client-go/v2/ioxsql),
97+
You can try the same with databases or data engines like
98+
[rqlite](https://github.com/rqlite/gorqlite?tab=readme-ov-file#driver-for-databasesql),
10099
[Dremio or Apache Drill](https://github.com/factset/go-drill), etc.
101100

102101
`usqlgen` also allows you to use alternative drivers of supported databases. Examples include:
103102

104-
- [github.com/microsoft/gocosmos](https://github.com/microsoft/gocosmos) - an official copy/fork of the unofficial driver included in `usql`
103+
- [github.com/microsoft/gocosmos](https://github.com/microsoft/gocosmos) - an official mirror of the unofficial driver
104+
included in `usql`
105105
- [github.com/sclgo/impala-go](https://github.com/sclgo/impala-go) - modernized variant of the built-in [Apache Impala](https://impala.apache.org/) driver
106106
- [github.com/mailru/go-clickhouse/v2](https://github.com/mailru/go-clickhouse) - HTTP-only alternative of the built-in Clickhouse driver
107-
- [github.com/sclgo/duckdb-adbc-go](https://github.com/sclgo/duckdb-adbc-go) - alternative driver for DuckDB that uses [its ADBC C API](https://duckdb.org/docs/clients/adbc)
107+
- [github.com/sclgo/adbcduck-go](https://github.com/sclgo/adbcduck-go) - alternative driver for DuckDB that
108+
uses [its ADBC C API](https://duckdb.org/docs/clients/adbc)
108109

109110
For more options, see `usqlgen --help` or review the examples below.
110111

111112
## Limitations
112113

113114
Most `usql` [backslash (meta) commands](https://github.com/xo/usql?tab=readme-ov-file#backslash-commands) work
114115
with new drivers added with `--import`, including
115-
[cross-database `\copy`](https://github.com/xo/usql?tab=readme-ov-file#copying-between-databases).
116-
Informational commands and autocomplete won't work though.
116+
[cross-database `\copy`](https://github.com/xo/usql?tab=readme-ov-file#copying-between-databases).
117+
Informational commands and autocomplete won't work though - [for now](https://github.com/sclgo/usqlgen/issues/50).
117118

118119
`usql` requires that connection strings are valid URIs or URLs, at least according to the Go `net/url` parsing algorithm.
119120
If you get an error that parameter in the form `driverName:dsn` can't be parsed as a URL,
120121
start `usql` without a connection string - in interactive mode or with the `-f` parameter. `usql` will start not connected to a DB.
121122
Then use the `\connect` command with two arguments driverName and dsn. In the `monetdb` example above, that would be:
122-
`\connect monetdb monetdb:password@localhost:50000/monetdb`
123+
`\connect monetdb monetdb:password@localhost:50000/monetdb`.
124+
125+
## CGO usage
126+
127+
`usqlgen build` and `usqlgen install` usually require support for [CGO](https://pkg.go.dev/cmd/cgo) to compile
128+
the generated `usql` codebase. If you need to avoid depending on CGO:
129+
130+
- don't import drivers that use CGO. The driver documentation should mention such usage.
131+
- exclude `usql` base drivers that depend on CGO by adding `-- -tags no_sqlite3` to the `usqlgen` command-line
132+
133+
If the system doesn't support CGO you may see errors like this when running `usqlgen build` or `install`:
134+
135+
```bash
136+
# github.com/xo/usql/drivers/sqlite3
137+
drivers/sqlite3/sqlite3.go:31:29: undefined: sqlite3.Error
138+
drivers/sqlite3/sqlite3.go:35:29: undefined: sqlite3.ErrNo
139+
```
140+
141+
In the future, `usqlgen` will [automatically exclude](https://github.com/sclgo/usqlgen/issues/51)
142+
default drivers that depend on CGO and weren't explicitly requested.
143+
`usqlgen` itself does not require `CGO` to compile or install.
123144

124145
## Examples
125146

126147
### Installing the customized `usql`
127148

128149
Use `usqlgen install ...` to install the customized `usql` to `GOPATH/bin` which is
129-
typically on the search path.
150+
typically on the search path. This runs `go install` internally.
130151

131152
```shell
132153
usqlgen install --import "github.com/MonetDB/MonetDB-Go/v2"

0 commit comments

Comments
 (0)