mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
Documentation.
This commit is contained in:
@@ -30,8 +30,10 @@ For non-WAL databases, `NORMAL` locking mode can be activated with
|
|||||||
[`PRAGMA locking_mode=NORMAL`](https://www.sqlite.org/pragma.html#pragma_locking_mode).
|
[`PRAGMA locking_mode=NORMAL`](https://www.sqlite.org/pragma.html#pragma_locking_mode).
|
||||||
|
|
||||||
Because connection pooling is incompatible with `EXCLUSIVE` locking mode,
|
Because connection pooling is incompatible with `EXCLUSIVE` locking mode,
|
||||||
the `database/sql` driver defaults to `NORMAL` locking mode,
|
the `database/sql` driver defaults to `NORMAL` locking mode.
|
||||||
and WAL databases are not supported.
|
To open WAL databases, or use `EXCLUSIVE` locking mode,
|
||||||
|
disable connection pooling by calling
|
||||||
|
[`db.SetMaxOpenConns(1)`](https://pkg.go.dev/database/sql#DB.SetMaxOpenConns).
|
||||||
|
|
||||||
#### Open File Description Locks
|
#### Open File Description Locks
|
||||||
|
|
||||||
|
|||||||
6
conn.go
6
conn.go
@@ -3,6 +3,7 @@ package sqlite3
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -91,8 +92,11 @@ func (c *Conn) openDB(filename string, flags OpenFlag) (uint32, error) {
|
|||||||
pragmaPtr := c.arena.string(pragmas.String())
|
pragmaPtr := c.arena.string(pragmas.String())
|
||||||
r := c.call(c.api.exec, uint64(handle), uint64(pragmaPtr), 0, 0, 0)
|
r := c.call(c.api.exec, uint64(handle), uint64(pragmaPtr), 0, 0, 0)
|
||||||
if err := c.module.error(r[0], handle, pragmas.String()); err != nil {
|
if err := c.module.error(r[0], handle, pragmas.String()); err != nil {
|
||||||
|
if errors.Is(err, ERROR) {
|
||||||
|
err = fmt.Errorf("sqlite3: invalid _pragma: %w", err)
|
||||||
|
}
|
||||||
c.closeDB(handle)
|
c.closeDB(handle)
|
||||||
return 0, fmt.Errorf("sqlite3: invalid _pragma: %w", err)
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return handle, nil
|
return handle, nil
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ var (
|
|||||||
// Ensure these interfaces are implemented:
|
// Ensure these interfaces are implemented:
|
||||||
_ driver.ExecerContext = conn{}
|
_ driver.ExecerContext = conn{}
|
||||||
_ driver.ConnBeginTx = conn{}
|
_ driver.ConnBeginTx = conn{}
|
||||||
|
_ driver.Validator = conn{}
|
||||||
_ sqlite3.DriverConn = conn{}
|
_ sqlite3.DriverConn = conn{}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -103,6 +104,11 @@ func (c conn) Close() error {
|
|||||||
return c.conn.Close()
|
return c.conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c conn) IsValid() (valid bool) {
|
||||||
|
r, err := c.conn.Pragma("locking_mode")
|
||||||
|
return err == nil && len(r) == 1 && r[0] == "normal"
|
||||||
|
}
|
||||||
|
|
||||||
func (c conn) Begin() (driver.Tx, error) {
|
func (c conn) Begin() (driver.Tx, error) {
|
||||||
return c.BeginTx(context.Background(), driver.TxOptions{})
|
return c.BeginTx(context.Background(), driver.TxOptions{})
|
||||||
}
|
}
|
||||||
|
|||||||
15
embed/README.md
Normal file
15
embed/README.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Embeddable WASM build of SQLite
|
||||||
|
|
||||||
|
This folder includes an embeddable WASM build of SQLite 3.41.0 for use with
|
||||||
|
[`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3).
|
||||||
|
|
||||||
|
The following optional features are compiled in:
|
||||||
|
- math functions
|
||||||
|
- FTS3/4/5
|
||||||
|
- JSON
|
||||||
|
- R*Tree
|
||||||
|
- GeoPoly
|
||||||
|
|
||||||
|
See the [configuration options](../sqlite3/sqlite_cfg.h).
|
||||||
|
|
||||||
|
Built using [`zig`](https://ziglang.org/) version 0.10.1.
|
||||||
@@ -4,12 +4,6 @@
|
|||||||
// with an appropriate build of SQLite:
|
// with an appropriate build of SQLite:
|
||||||
//
|
//
|
||||||
// import _ "github.com/ncruces/go-sqlite3/embed"
|
// import _ "github.com/ncruces/go-sqlite3/embed"
|
||||||
//
|
|
||||||
// The following optional features are compiled in:
|
|
||||||
// math functions, JSON, FTS3/4/5, R*Tree, GeoPoly.
|
|
||||||
//
|
|
||||||
// You can obtain this build of SQLite from:
|
|
||||||
// https://github.com/ncruces/go-sqlite3/tree/main/embed
|
|
||||||
package embed
|
package embed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Reference in New Issue
Block a user