Skip to content

Commit

Permalink
docs: add a new description on new query params supported due to the …
Browse files Browse the repository at this point in the history
…sqlite drive change
  • Loading branch information
danvergara committed Jun 12, 2024
1 parent 70cfbf2 commit 37036a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ build:
CGO_ENABLED=0 \
go build -o dblab .

.PHONY: build-sqlite3
## build-sqlite3: Builds the Go program with CGO_ENABLED enabled.
build-sqlite3:
CGO_ENABLED=0 \
go build -o dblab .

.PHONY: run
## run: Runs the application
run: build
Expand Down Expand Up @@ -74,10 +68,14 @@ run-mysql-socket-url: build

.PHONY: run-sqlite3
## run-sqlite3: Runs the application with a connection to sqlite3
run-sqlite3: build-sqlite3
docker compose run --rm dblab-sqlite3
run-sqlite3: build
./dblab --db db/dblab.db --driver sqlite

.PHONY: run-sqlite3-url
## run-sqlite3-url: Runs the application with a connection string to sqlite3
run-sqlite3-url: build
./dblab --url 'file:db/dblab.db?_pragma=foreign_keys(1)&_time_format=sqlite'

.PHONY: run-url
## run-url: Runs the app passing the url as parameter
run-url: build
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Connection URL scheme is also supported:
```sh
$ dblab --url 'postgres://user:password@host:port/database?sslmode=[mode]'
$ dblab --url 'mysql://user:password@tcp(host:port)/db'
$ dblab --url 'file:test.db?cache=shared&mode=memory'
$ dblab --url 'file:test.db?_pragma=foreign_keys(1)&_time_format=sqlite'
$ dblab --url 'oracle://user:password@localhost:1521/db'
```

Expand Down
5 changes: 4 additions & 1 deletion pkg/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ func BuildConnectionFromOpts(opts command.Options) (string, command.Options, err
return conn, opts, err
}

// this options is for sqlite.
// This options is for sqlite.
// For more information see https://github.com/mattn/go-sqlite3#connection-string.
// The sqlite driver is modernc.org/sqlite now, so the query params changed.
// mattn's driver and modernc.org's differ in the query paremeters they use to perform a connection.
// To know more about the connection and query paremeters see: https://pkg.go.dev/modernc.org/sqlite#Driver.Open
if strings.HasPrefix(opts.URL, "file:") {
opts.Driver = drivers.SQLite
return opts.URL, opts, nil
Expand Down

0 comments on commit 37036a5

Please sign in to comment.