Low-level Go interface to SQLite 3

Overview

zombiezen.com/go/sqlite

Go Reference

This package provides a low-level Go interface to SQLite 3. It is a fork of crawshaw.io/sqlite that uses modernc.org/sqlite, a CGo-free SQLite package. It aims to be a mostly drop-in replacement for crawshaw.io/sqlite.

Features

Install

go get zombiezen.com/go/sqlite

While this library does not use CGo, make sure that you are building for one of the supported architectures.

Getting Started

import (
  "fmt"

  "zombiezen.com/go/sqlite"
  "zombiezen.com/go/sqlite/sqlitex"
)

// ...

// Open an in-memory database.
conn, err := sqlite.OpenConn(":memory:", sqlite.OpenReadWrite)
if err != nil {
  return err
}
defer conn.Close()

// Execute a query.
err = sqlitex.ExecTransient(conn, "SELECT 'hello, world';", func(stmt *sqlite.Stmt) error {
  fmt.Println(stmt.ColumnText(0))
  return nil
})
if err != nil {
  return err
}

If you're creating a new application, see the package examples or the reference docs.

If you're looking to switch existing code that uses crawshaw.io/sqlite, take a look at the migration docs.

License

ISC

Comments
  • Question about performance

    Question about performance

    Hello,

    I was searching for alternatives to mattn/go-sqlite3 and came across this library. I really like it so far!

    But because I don't just want to make my Go programs a lot slower, I thought about doing some benchmarks first. (I'm new to benchmarking in Go!) You can see them here: https://git.jlel.se/jlelse/GoSqliteBench/src/commit/12db3eac1fd3c0d32e078e9a2d8feb917e83df84/SqliteBench_test.go

    Unfortunately the results look like this:

    $ go test -bench=.
    goos: linux
    goarch: amd64
    pkg: git.jlel.se/jlelse/GoSqliteBench
    cpu: Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
    Benchmark_Zombiezen/Queries-4             149104              7141 ns/op
    Benchmark_Mattn/Queries-4                 269184              4256 ns/op
    PASS
    ok      git.jlel.se/jlelse/GoSqliteBench        3.274s
    

    Am I doing something wrong? Why is this library so much slower?

    question 
    opened by jlelse 7
  • sqlitex.Pool.Get should never return a nil Conn — click here to learn more!

    sqlitex.Pool.Get should never return a nil Conn — click here to learn more!

    Right now, sqlitex.Pool.Get can return a nil Conn in a few circumstances, for example if the pool has been closed, or if the provided context has been canceled. This means consumers can't safely use the normal Get/defer Put idiom.

    conn := pool.Get(ctx)
    defer pool.Put(conn)
    // use conn
    

    And instead must do an explicit nil check within each stanza.

    conn := pool.Get(ctx)
    if conn == nil {
        // return
    }
    defer pool.Put(conn)
    // use conn
    

    It would be better if the Get method always returned a non-nil Conn, and, in the situations where it's not actually usable, have all of its methods short-circuit and return an appropriate error.

    enhancement 
    opened by peterbourgon 7
  • Transaction helpers don't work when manual BEGIN/END do

    Transaction helpers don't work when manual BEGIN/END do

    Using sqlitex.Transaction I get a lot of:

    sqlite: step: database is locked: cannot commit transaction - SQL statements in progress
    

    But if I manually sqlitex.Exec(... "BEGIN") and "END", I don't have this problem. Is there a difference I should be aware of?

    question 
    opened by anacrolix 5
  • sqlitemigration: Use table instead of pragma user_version

    sqlitemigration: Use table instead of pragma user_version

    I believe SQLite's PRAGMA user_version is one of those shiny traps. It looks like it'll do what you want for schema migrations, but it's not included in a database dump. Dump+restore will confuse your schema migration mechanism.

    Instead, please consider using a table to store the schema version.

    For inspiration: https://github.com/tv42/securityblanket/tree/master/internal/schema

    opened by tv42 4
  • "Disable double-quoted string literals" broke my usage

    Commit ed99db83671cdf65aeb34b1bcd490ba66d712e97 made it so the query

    SELECT count() FROM objects WHERE id == "baz";
    

    which previously returned 0, to error with

    sqlutil.Exec: sqlite: prepare "SELECT count() FROM objects WHERE id == \"baz\"": SQL logic error: no such column: baz
    

    Am I doing something wrong?

    opened by peterbourgon 3
  • Build error in Windows with

    Build error in Windows with "set GOARCH=386"

    My OS is Windows-32bit.

    When I try to build my golang program:

    set GOARCH=386 go build .

    I got this error messages:

    zombiezen.com/go/sqlite

    C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:68:20: undefined: sqlite3.Xsqlite3session_create C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:90:2: undefined: sqlite3.Xsqlite3session_delete C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:725:37: undefined: sqlite3.SQLITE_CHANGESET_DATA C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:726:37: undefined: sqlite3.SQLITE_CHANGESET_NOTFOUND C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:727:37: undefined: sqlite3.SQLITE_CHANGESET_CONFLICT C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:728:37: undefined: sqlite3.SQLITE_CHANGESET_CONSTRAINT C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:729:37: undefined: sqlite3.SQLITE_CHANGESET_FOREIGN_KEY C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:761:33: undefined: sqlite3.SQLITE_CHANGESET_OMIT C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:765:34: undefined: sqlite3.SQLITE_CHANGESET_ABORT C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:779:36: undefined: sqlite3.SQLITE_CHANGESET_REPLACE C:\Users\username\go\pkg\mod\zombiezen.com\go\[email protected]\session.go:90:2: too many errors

    But it's OK in "windows-amd64" and "linux-386" and "linux-arm" and "linux-arm64".

    opened by hgmmym 2
  • Expose valid int64 types

    Expose valid int64 types

    Get/SetInt64 is great but per the SQLite docs...

    INTEGER. The value is a signed integer, stored in 0, 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.

    This would be we should be able to use

    byte
    int8
    int16
    int32
    int64
    uint8
    uint16
    uint32
    uint64
    

    By using the proper size we eliminate extra casting and memory allocations

    opened by delaneyj 2
  • Panic in migration tool on anacrolix/torrent

    Panic in migration tool on anacrolix/torrent

    Brilliant project idea. I decided to try it out in some of my usage of crawshaw.io/sqlite. Running cmd/[email protected] on https://github.com/anacrolix/torrent/commit/8e5ae65837e395430c1c202eb9274f3af335e83c:

    ~/go/src/github.com/anacrolix/torrent$ zombiezen-sqlite-migrate ./...
    zombiezen-sqlite-migrate: loading packages...
    zombiezen-sqlite-migrate: packages loaded
    diff -u /Users/anacrolix/go/src/github.com/anacrolix/torrent/storage/sqlite-piece-completion.go /var/folders/rx/s8fbr8m17nvg88dq7lkblhz00000gn/T/zombiezen-sqlite-1540460039.go
    --- /Users/anacrolix/go/src/github.com/anacrolix/torrent/storage/sqlite-piece-completion.go	2021-11-01 11:46:47.000000000 +1100
    +++ /var/folders/rx/s8fbr8m17nvg88dq7lkblhz00000gn/T/zombiezen-sqlite-1540460039.go	2021-11-19 15:47:18.000000000 +1100
    @@ -8,9 +8,9 @@
     	"path/filepath"
     	"sync"
     
    -	"crawshaw.io/sqlite"
    -	"crawshaw.io/sqlite/sqlitex"
     	"github.com/anacrolix/torrent/metainfo"
    +	"zombiezen.com/go/sqlite"
    +	"zombiezen.com/go/sqlite/sqlitex"
     )
     
     type sqlitePieceCompletion struct {
    panic: interface conversion: types.Type is *types.Interface, not *types.Named [recovered]
    	panic: interface conversion: types.Type is *types.Interface, not *types.Named
    
    goroutine 1 [running]:
    golang.org/x/tools/go/ast/astutil.Apply.func1()
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:47 +0x89
    panic({0x124f280, 0xc00190c330})
    	/Users/anacrolix/src/go1.17/src/runtime/panic.go:1038 +0x215
    main.process.func1(0xc001eba250)
    	/Users/anacrolix/go/pkg/mod/zombiezen.com/go/sqlite/cmd/[email protected]/migrate.go:326 +0xc52
    golang.org/x/tools/go/ast/astutil.(*application).apply(0xc001eba240, {0x12f79c0, 0xc001b97fc0}, {0x1285cfd, 0xc001b97fc0}, 0x123cd60, {0x12f7b28, 0xc00207dea0})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:198 +0x202
    golang.org/x/tools/go/ast/astutil.(*application).applyList(0xc001eba240, {0x12f79c0, 0xc001b97fc0}, {0x1285cfd, 0x5})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:473 +0xae
    golang.org/x/tools/go/ast/astutil.(*application).apply(0xc001eba240, {0x12f79e8, 0xc001b377d0}, {0x12855f9, 0x0}, 0x8, {0x12f79c0, 0xc001b97fc0})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:220 +0x15f5
    golang.org/x/tools/go/ast/astutil.(*application).applyList(0xc001eba240, {0x12f79e8, 0xc001b377d0}, {0x12855f9, 0x4})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:473 +0xae
    golang.org/x/tools/go/ast/astutil.(*application).apply(0xc001eba240, {0x12f7bf0, 0xc002113980}, {0x1287927, 0x0}, 0x0, {0x12f79e8, 0xc001b377d0})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:226 +0x1ba5
    golang.org/x/tools/go/ast/astutil.(*application).apply(0xc001eba240, {0x12f79c0, 0xc0016c6000}, {0x1285731, 0x5}, 0xc000ae13b0, {0x12f7bf0, 0xc002113980})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:295 +0x1352
    golang.org/x/tools/go/ast/astutil.(*application).apply(0xc001eba240, {0x12f79e8, 0xc001b37800}, {0x12855f9, 0x8}, 0xc000ae13a8, {0x12f79c0, 0xc0016c6000})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/too[email protected]/go/ast/astutil/rewrite.go:221 +0x1645
    golang.org/x/tools/go/ast/astutil.(*application).applyList(0xc001eba240, {0x12f79e8, 0xc001b37800}, {0x12855f9, 0x4})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:473 +0xae
    golang.org/x/tools/go/ast/astutil.(*application).apply(0xc001eba240, {0x12f7ab0, 0xc0021139f8}, {0x12868f9, 0x4}, 0x0, {0x12f79e8, 0xc001b37800})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:226 +0x1ba5
    golang.org/x/tools/go/ast/astutil.(*application).apply(0xc001eba240, {0x12f7a60, 0xc001b37950}, {0x1285731, 0x1015c0f}, 0x0, {0x12f7ab0, 0xc0021139f8})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:291 +0x6e5
    golang.org/x/tools/go/ast/astutil.(*application).apply(0xc001eba240, {0x12f8320, 0xc00157e3b0}, {0x1285645, 0x28}, 0x28, {0x12f7a60, 0xc001b37950})
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:417 +0x17b1
    golang.org/x/tools/go/ast/astutil.Apply({0x12f7a60, 0xc001b37950}, 0xc00190c300, 0x0)
    	/Users/anacrolix/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:52 +0x166
    main.process(0xc0007ede60, 0xc001c7d580)
    	/Users/anacrolix/go/pkg/mod/zombiezen.com/go/sqlite/cmd/[email protected]/migrate.go:304 +0x454
    main.run({0x12f94a8, 0xc000104780}, 0x0, {0xc000010050, 0x1, 0x1})
    	/Users/anacrolix/go/pkg/mod/zombiezen.com/go/sqlite/cmd/[email protected]/migrate.go:58 +0x4fa
    main.main()
    	/Users/anacrolix/go/pkg/mod/zombiezen.com/go/sqlite/cmd/[email protected]/migrate.go:35 +0x145
    
    bug 
    opened by anacrolix 2
  • Support for Changesets

    Support for Changesets

    Migrating from https://pkg.go.dev/crawshaw.io/sqlite but I'm missing the Changeset support. Any plans for implementation, would it be a welcome addition?

    enhancement 
    opened by emcfarlane 2
  • Bump actions/checkout from 2 to 2.3.4

    Bump actions/checkout from 2 to 2.3.4

    Bumps actions/checkout from 2 to 2.3.4.

    Release notes

    Sourced from actions/checkout's releases.

    v2.3.4

    v2.3.3

    v2.3.2

    Add Third Party License Information to Dist Files

    v2.3.1

    Fix default branch resolution for .wiki and when using SSH

    v2.3.0

    Fallback to the default branch

    v2.2.0

    Fetch all history for all tags and branches when fetch-depth=0

    v2.1.1

    Changes to support GHES (here and here)

    v2.1.0

    Changelog

    Sourced from actions/checkout's changelog.

    Changelog

    v2.3.1

    v2.3.0

    v2.2.0

    v2.1.1

    • Changes to support GHES (here and here)

    v2.1.0

    v2.0.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 2
  • Add ability to check that all `sqlitex.Exec*` parameters have been set

    Add ability to check that all `sqlitex.Exec*` parameters have been set

    An interesting observation that @anacrolix made on #30:

    Adds optional checking that all parameters are set. I've been burned so many times by not setting parameters. I'm using this successfully in a production system. Interestingly the tests pass, I guess there's no tests for missing parameters.

    I'm not sure that I want to add this to the existing API surface, since it could constitute a breaking change (what if someone is using the NULL default intentionally?), but I could be more easily convinced that any of the new ExecOptions-based functions (include those to be added for #5) could have this check by default.

    enhancement 
    opened by zombiezen 1
  • Log the generated SQL statement

    Log the generated SQL statement

    Hello @zombiezen, Thanks for this repo, been using this library in my side projects for couple of months now. I have one question, Is there anyway I can get the the generated SQL statement print it out to stdout? or possibly passing a logger?

    Thank you

    enhancement 
    opened by alinz 2
  • Helper functions for time.Time

    Helper functions for time.Time

    I'd be nice to be able to have Get/Set of time.Time directly. Versions for rfc3339, int64 unix sec && int64 unix milliseconds it what i tend to use most. Are you open to PRs?

    enhancement 
    opened by delaneyj 4
  • Xsqlite3_open_v2 (via sqlitex.Open) needs to be synchronized

    Xsqlite3_open_v2 (via sqlitex.Open) needs to be synchronized

    module temp
    
    go 1.16
    
    require zombiezen.com/go/sqlite v0.5.0 // indirect
    
    package main
    
    import (
            "context"
            "fmt"
            "sync"
    
            "zombiezen.com/go/sqlite"
            "zombiezen.com/go/sqlite/sqlitex"
    )
    
    func main() {
            var wg sync.WaitGroup
            for i := 0; i < 32; i++ {
                    go func() { defer wg.Done(); f() }()
            }
            wg.Wait()
    }
    
    func f() {
            var (
                    ctx      = context.Background()
                    uri      = "file::memory:?mode=memory&cache=shared"
                    flags    = sqlite.OpenReadWrite | sqlite.OpenCreate | sqlite.OpenURI | sqlite.OpenNoMutex
                    poolSize = 32
            )
    
            pool, err := sqlitex.Open(uri, flags, poolSize)
            if err != nil {
                    panic(err)
            }
            defer pool.Close()
    
            conn := pool.Get(ctx)
            if conn == nil {
                    panic(fmt.Errorf("nil conn"))
            }
            defer pool.Put(conn)
    
            if err := sqlitex.Exec(conn, `SELECT 1;`, nil); err != nil {
                    panic(err)
            }
    }
    
    $ go run -race main.go
    ==================
    WARNING: DATA RACE
    Read at 0x000001b620d4 by goroutine 20:
      modernc.org/sqlite/lib.Xsqlite3_initialize()
          /Users/pbourgon/pkg/mod/modernc.org/[email protected]/lib/sqlite_darwin_amd64.go:158713 +0x158
      modernc.org/sqlite/lib.openDatabase()
          /Users/pbourgon/pkg/mod/modernc.org/[email protected]/lib/sqlite_darwin_amd64.go:161013 +0x364
      modernc.org/sqlite/lib.Xsqlite3_open_v2()
          /Users/pbourgon/pkg/mod/modernc.org/[email protected]/lib/sqlite_darwin_amd64.go:161348 +0x684
      zombiezen.com/go/sqlite.openConn()
          /Users/pbourgon/pkg/mod/zombiezen.com/go/[email protected]/sqlite.go:136 +0x648
      zombiezen.com/go/sqlite.OpenConn()
          /Users/pbourgon/pkg/mod/zombiezen.com/go/[email protected]/sqlite.go:80 +0xe7
      zombiezen.com/go/sqlite/sqlitex.Open()
          /Users/pbourgon/pkg/mod/zombiezen.com/go/[email protected]/sqlitex/pool.go:103 +0x2e8
      main.f()
          /var/folders/m4/192hdv6n19j9x2v86k1r29rw0000gn/T/tmp.z2VKC9Xr/main.go:28 +0x8f
      main.main.func1()
          /var/folders/m4/192hdv6n19j9x2v86k1r29rw0000gn/T/tmp.z2VKC9Xr/main.go:15 +0x64
    
    Previous write at 0x000001b620d4 by goroutine 19:
      modernc.org/sqlite/lib.Xsqlite3_initialize()
          /Users/pbourgon/pkg/mod/modernc.org/[email protected]/lib/sqlite_darwin_amd64.go:158728 +0x65b
      modernc.org/sqlite/lib.openDatabase()
          /Users/pbourgon/pkg/mod/modernc.org/[email protected]/lib/sqlite_darwin_amd64.go:161013 +0x364
      modernc.org/sqlite/lib.Xsqlite3_open_v2()
          /Users/pbourgon/pkg/mod/modernc.org/[email protected]/lib/sqlite_darwin_amd64.go:161348 +0x684
      zombiezen.com/go/sqlite.openConn()
          /Users/pbourgon/pkg/mod/zombiezen.com/go/[email protected]/sqlite.go:136 +0x648
      zombiezen.com/go/sqlite.OpenConn()
          /Users/pbourgon/pkg/mod/zombiezen.com/go/[email protected]/sqlite.go:80 +0xe7
      zombiezen.com/go/sqlite/sqlitex.Open()
          /Users/pbourgon/pkg/mod/zombiezen.com/go/[email protected]/sqlitex/pool.go:103 +0x2e8
      main.f()
          /var/folders/m4/192hdv6n19j9x2v86k1r29rw0000gn/T/tmp.z2VKC9Xr/main.go:28 +0x8f
      main.main.func1()
          /var/folders/m4/192hdv6n19j9x2v86k1r29rw0000gn/T/tmp.z2VKC9Xr/main.go:15 +0x64
    
    Goroutine 20 (running) created at:
      main.main()
          /var/folders/m4/192hdv6n19j9x2v86k1r29rw0000gn/T/tmp.z2VKC9Xr/main.go:15 +0x94
    
    Goroutine 19 (running) created at:
      main.main()
          /var/folders/m4/192hdv6n19j9x2v86k1r29rw0000gn/T/tmp.z2VKC9Xr/main.go:15 +0x94
    ==================
    Found 1 data race(s)
    exit status 66
    

    Protecting the OpenConn call with a mutex solves it, apparently.

    bug 
    opened by peterbourgon 1
  • Migrate test code in migration tool

    Migrate test code in migration tool

    https://github.com/zombiezen/go-sqlite/blob/88da00a4e88fcd2c572032dacaec6c3d0ba7faee/cmd/zombiezen-sqlite-migrate/migrate.go#L42

    I also want the tool to rewrite _test.go files. I'll need to keep track of files so I don't double-process a file.

    enhancement 
    opened by zombiezen 0
Releases(v0.11.0)
  • v0.11.0(Dec 12, 2022)

    Version 0.11 changes the aggregate function API.

    Changed

    • User-defined aggregate functions are now encapsulated with a new interface, AggregateFunction. The previous 4-callback approach has been removed and replaced with a single MakeAggregate callback. Not only was the previous API unwieldy, but it failed to handle concurrent aggregate function calls in a single query.
    • Minimum modernc.org/sqlite version updated to 1.20.0.
    Source code(tar.gz)
    Source code(zip)
  • v0.11.0-beta1(Jul 19, 2022)

  • v0.10.1(Jul 17, 2022)

    Version 0.10.1 fixes a bug in user-defined window functions. Special thanks to Jan Mercl for assistance in debugging this issue.

    Fixed

    • AggregateFinal is now called correctly at the end of window functions' usages.
    Source code(tar.gz)
    Source code(zip)
  • v0.10.0(Jul 17, 2022)

  • v0.9.3(May 30, 2022)

  • v0.9.2(Jan 25, 2022)

    Version 0.9 adds new Execute functions to sqlitex and changes the default blocking behavior. Version 0.9 also includes various fixes to the schema migration behavior.

    Added

    • Added SetBlockOnBusy method to set an indefinite timeout on acquiring a lock.
    • Official support for windows/amd64.
    • sqlitex has three new functions — Execute, ExecuteTransient, and ExecuteScript — that take in an ExecOptions struct. (#5)
    • New method sqlite.ResultCode.ToError to create error values.
    • New methods ColumnBool and GetBool on *sqlite.Stmt (#37).

    Changed

    • OpenConn calls SetBlockOnBusy on new connections instead of SetBusyTimeout(10 * time.Second).
    • The sqlitex.Execute* family of functions now verify that the arguments passed match the SQL parameters. (#31)

    Deprecated

    • sqlitex.ExecFS has been renamed to sqlitex.ExecuteFS, sqlitex.ExecTransientFS has been renamed to sqlitex.ExecuteTransientFS, and sqlitex.ExecScriptFS has been renamed to sqlitex.ExecuteScriptFS for consistency with the new Execute functions. Aliases remain in this version, but will be removed in the next version. Use zombiezen-sqlite-migrate to clean up existing references.
    • sqlitex.Exec and sqlitex.ExecTransient have been marked deprecated because they do not perform the argument checks that the Execute functions now perform. These functions will remain into 1.0 and beyond for compatibility, but should not be used in new applications.

    Fixed

    • sqlitemigration.Schema.RepeatableMigration is now run as part of the final transaction. This ensures that the repeatable migration for migration N has executed if and only if user_version == N. Previously, the repeatable migration could fail independently of the final transaction, which would mean that a subsequent migration run would not trigger a retry of the repeatable transaction, but report success.
    • sqlitemigration will no longer skip applying the repeatable migration if the final migration is empty.
    • OpenConn now sets a busy handler before enabling WAL (thanks @anacrolix!).
    Source code(tar.gz)
    Source code(zip)
  • v0.9.0-beta1(Dec 3, 2021)

  • v0.8.0(Nov 7, 2021)

    Version 0.8 adds new transaction functions to sqlitex.

    Added

    • Added sqlitex.Transaction, sqlitex.ImmediateTransaction, and sqlitex.ExclusiveTransaction.
    Source code(tar.gz)
    Source code(zip)
  • v0.7.2(Sep 11, 2021)

  • v0.7.1(Sep 10, 2021)

  • v0.7.0(Aug 27, 2021)

    Added

    • sqlitemigration.Schema has a new option for disabling foreign keys for individual migrations. This makes it easier to perform migrations that require reconstructing a table. (#20)

    Changed

    • sqlitemigration.Migrate and *sqlitemigration.Pool no longer use a transaction to apply the entire set of migrations: they now only use transactions during each individual migration. This was never documented, so in theory no one should be depending on this behavior. However, this does mean that two processes trying to open and migrate a database concurrently may race to apply migrations, whereas before only one process would acquire the write lock and migrate.

    Fixed

    • Fixed compile breakage on 32-bit architectures. Thanks to Jan Mercl for the report.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.2(Aug 17, 2021)

  • v0.6.1(Aug 17, 2021)

  • v0.6.0(Aug 15, 2021)

    Added

    • Added back the session API: Session, ChangesetIterator, Changegroup, and various functions. There are some slight naming changes from the crawshaw.io/sqlite API, but they can all be migrated automatically with the migration tool. (#16)

    Changed

    • Method calls to a nil *sqlite.Conn will return an error rather than panic. (#17)

    Removed

    • Removed OpenFlags that are only used for VFS.

    Fixed

    • Properly clean up WAL when using sqlitex.Pool (#14)
    • Disabled double-quoted string literals.
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(May 22, 2021)

    Added

    • Added shell package with basic REPL
    • Added SetAuthorizer, Limit, and SetDefensive methods to *Conn for use in (#12)
    • Added Version and VersionNumber constants

    Fixed

    • Documented compiled-in extensions (#11)
    • Internal objects are no longer susceptible to ID wraparound issues (#13)
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(May 14, 2021)

  • v0.3.1(May 4, 2021)

  • v0.3.0(Apr 27, 2021)

    • Implement io.StringWriter, io.ReaderFrom, and io.WriterTo on Blob (#2)
    • Add godoc examples for Blob, sqlitemigration, and SetInterrupt
    • Add more README documentation
    Source code(tar.gz)
    Source code(zip)
  • v0.2.2(Apr 24, 2021)

  • v0.2.1(Apr 17, 2021)

  • v0.2.0(Apr 3, 2021)

    Added

    • New migration tool. See the README to get started. (#1)

    Changed

    • *Conn.CreateFunction has changed entirely. See the reference for details.
    • sqlitex.File and sqlitex.Buffer have been moved to the sqlitefile package
    • The sqlitefile.Exec* functions have been moved to the sqlitex package as Exec*FS.
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Apr 1, 2021)

Owner
Ross Light
Gopher @YourBase. Former TL of Go CDK and author of Wire. he/him
Ross Light
Convert data exports from various services to a single SQLite database

Bionic Bionic is a tool to convert data exports from web apps to a single SQLite database. Bionic currently supports data exports from Google, Apple H

Bionic 175 Dec 9, 2022
Pure Go SQLite file reader

Package SQLittle provides pure Go, read-only, access to SQLite (version 3) database files. What SQLittle reads SQLite3 tables and indexes. It iterates

Harmen 186 Oct 12, 2022
Streaming replication for SQLite.

Litestream Litestream is a standalone streaming replication tool for SQLite. It runs as a background process and safely replicates changes incremental

Ben Johnson 7.9k Jan 9, 2023
Go sqlite3 http vfs: query sqlite databases over http with range headers

sqlite3vfshttp: a Go sqlite VFS for querying databases over http(s) sqlite3vfshttp is a sqlite3 VFS for querying remote databases over http(s). This a

Peter Sanford 114 Dec 27, 2022
BQB is a lightweight and easy to use query builder that works with sqlite, mysql, mariadb, postgres, and others.

Basic Query Builder Why Simple, lightweight, and fast Supports any and all syntax by the nature of how it works Doesn't require learning special synta

Aaron M 61 Dec 7, 2022
Experimental implementation of a SQLite backend for go-mysql-server

go-mysql-sqlite-server This is an experimental implementation of a SQLite backend for go-mysql-server from DoltHub. The go-mysql-server is a "frontend

MergeStat 11 Dec 23, 2022
SQLite extension for accessing other SQL databases

dblite SQLite extension for accessing other SQL databases, in SQLite. Similar to how Postgres Foreign Data Wrappers enable access to other databases i

MergeStat 10 Dec 23, 2022
Golang database driver for SQLite

go-sqlite Golang database driver for SQLite. Does not use cgo. This driver is based on pure-Go SQLite implementation (https://gitlab.com/cznic/sqlite)

glebarez 170 Dec 30, 2022
RecordLite: a library (and executable) that declaratively maintains SQLite tables and views of semi-structured data

RecordLite RecordLite is a library (and executable) that declaratively maintains

François Saint-Jacques 22 May 29, 2022
Tracking down a Memory Leak in Go/SQLite

Tracking down a Memory Leak in Go/SQLite run make test - WARNING: long running - several minutes on my workstation OSs supported: Windows_NT => memory

Stefan Thiel 1 Feb 28, 2022
Dbench - An unscientific benchmark of SQLite vs the file system (btrfs)

DBENCH Basic benchmarks for SQLite vs file system (btrfs on a 2020 Dell XPS SSD)

Chris Davies 38 May 20, 2022
Sqlair - SQLite Query Layer With Golang

sqlair SQLite Query Layer Creates an abstract over the go sql package to provide

Simon Richardson 1 Feb 18, 2022
Simple key-value store on top of SQLite or MySQL

KV Work in progress, not ready for prime time. A simple key/value store on top of SQLite or MySQL (Go port of GitHub's KV). Aims to be 100% compatible

Sergio Rubio 4 Dec 3, 2022
Re-usable component for subscribing to row-level changes on a postgres database

pgreplicate Re-usable component for subscribing to row-level changes on a postgres database Development In order to run tests the postgres database ne

Crewlinker 0 Dec 21, 2021
Multitenancy in Postgres with Go using Row Level Security (RLS)

tenancy A Go library for multitenancy in Postgres using Row Level Security (RLS). Usage Tenancy as a connection pool. By default, tenancy.Open() begin

Common Fate 8 Oct 14, 2022
Universal command-line interface for SQL databases

usql A universal command-line interface for PostgreSQL, MySQL, Oracle Database, SQLite3, Microsoft SQL Server, and many other databases including NoSQ

XO 7.8k Jan 9, 2023
Interactive terminal user interface and CLI for database connections. MySQL, PostgreSQL. More to come.

?? dbui dbui is the terminal user interface and CLI for database connections. It provides features like, Connect to multiple data sources and instance

Kanan Rahimov 122 Jan 5, 2023
A project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol formatA project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol format

Intro This project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol format. It integrates nicely with the Telegraf execd inpu

Marc Venturini 1 Apr 15, 2022
This is a simple graph database in SQLite, inspired by "SQLite as a document database".

About This is a simple graph database in SQLite, inspired by "SQLite as a document database". Structure The schema consists of just two structures: No

Denis Papathanasiou 1.2k Jan 3, 2023
Package sqlite is a CGo-free port of SQLite.

sqlite Package sqlite is a CGo-free port of SQLite. SQLite is an in-process implementation of a self-contained, serverless, zero-configuration, transa

Joe 3 Nov 30, 2021