Skip to content

Commit

Permalink
Add modernc-sqlite to examples/all_adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
VinGarcia committed Oct 22, 2023
1 parent cf25954 commit 860b1cc
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 15 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ lint: setup go-mod-tidy
@echo "StaticCheck & Go Vet found no problems on your code!"

# Run go mod tidy for all submodules:
tidy: go-mod-tidy
go-mod-tidy:
find . -name go.mod -execdir go mod tidy \;

Expand Down
21 changes: 21 additions & 0 deletions examples/all_adapters/all_adapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/vingarcia/ksql/adapters/kpgx"
"github.com/vingarcia/ksql/adapters/ksqlite3"
"github.com/vingarcia/ksql/adapters/ksqlserver"
ksqlite "github.com/vingarcia/ksql/adapters/modernc-ksqlite"
)

// User ...
Expand Down Expand Up @@ -106,6 +107,26 @@ func main() {
}
defer db.Close()

// In the definition below, please note that BLOB is
// the only type we can use in sqlite for storing JSON.
_, err = db.Exec(ctx, `CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
age INTEGER,
name TEXT,
address BLOB
)`)
if err != nil {
log.Fatalf("unable to create users table: %s", err)
}
case "sqlite":
db, err = ksqlite.New(ctx, "/tmp/ksql.modernc-sqlite", ksql.Config{
MaxOpenConns: 1,
})
if err != nil {
log.Fatalf("unable to open database: %s", err)
}
defer db.Close()

// In the definition below, please note that BLOB is
// the only type we can use in sqlite for storing JSON.
_, err = db.Exec(ctx, `CREATE TABLE IF NOT EXISTS users (
Expand Down
17 changes: 5 additions & 12 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@ module alladapters

go 1.14

replace (
github.com/vingarcia/ksql => ../
github.com/vingarcia/ksql/adapters/kmysql => ../adapters/kmysql
github.com/vingarcia/ksql/adapters/kpgx => ../adapters/kpgx
github.com/vingarcia/ksql/adapters/ksqlite3 => ../adapters/ksqlite3
github.com/vingarcia/ksql/adapters/ksqlserver => ../adapters/ksqlserver
)

require (
github.com/golang/mock v1.6.0
github.com/jackc/pgtype v1.14.0
github.com/stretchr/testify v1.8.4
github.com/vingarcia/ksql v1.10.0
github.com/vingarcia/ksql/adapters/kmysql v0.0.0-00010101000000-000000000000
github.com/vingarcia/ksql/adapters/kpgx v0.0.0-00010101000000-000000000000
github.com/vingarcia/ksql/adapters/ksqlite3 v0.0.0-00010101000000-000000000000
github.com/vingarcia/ksql/adapters/ksqlserver v0.0.0-00010101000000-000000000000
github.com/vingarcia/ksql/adapters/kmysql v1.10.0
github.com/vingarcia/ksql/adapters/kpgx v1.10.0
github.com/vingarcia/ksql/adapters/ksqlite3 v1.10.0
github.com/vingarcia/ksql/adapters/ksqlserver v1.10.0
github.com/vingarcia/ksql/adapters/modernc-ksqlite v1.10.0
)
Loading

0 comments on commit 860b1cc

Please sign in to comment.