Documentation
¶
Overview ¶
Package enlite connects Ent's SQLite dialect to the cgo-free github.com/liustack/sqlite driver.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open creates an Ent driver backed by liustack/sqlite. Pass it to a generated client with ent.NewClient(ent.Driver(drv)). Closing the client closes the underlying database/sql pool. Use drv.DB() to access that pool directly.
Open parses the DSN and validates options. SQLite opens the first connection on demand. Use drv.DB().PingContext to check that the database can be opened. Foreign keys are enabled on each new connection by default. DSN PRAGMAs run after that default, and option PRAGMAs run last, in the order supplied.
A private in-memory or temporary database uses one open and idle connection because each connection otherwise gets a separate database. For a pooled in-memory database, use a URI such as file:/app?vfs=memdb.
Types ¶
type Option ¶
type Option func(*config) error
Option configures the database opened by Open.
func WithBusyTimeout ¶
WithBusyTimeout sets PRAGMA busy_timeout, including the upstream writer queue's wait limit. The duration must be a whole number of milliseconds between zero and 2147483647. Zero disables waiting on locks.
func WithPoolSize ¶
WithPoolSize sets both the maximum open connections and maximum idle connections. Connections retain their page cache while idle. Size must be positive and must be one for a private in-memory or temporary database.
func WithPragma ¶
WithPragma appends a SQLite PRAGMA expression, such as "journal_mode(WAL)". The upstream driver runs it on every physical connection. Use trusted SQL because the upstream driver evaluates this expression as SQL.
func WithSQLiteOptions ¶
WithSQLiteOptions passes upstream options to the connector for this pool. Use it to install SQL functions, collations, virtual tables or extensions such as regexp and uuid on every connection. Callbacks can run concurrently on different connections.
func WithTxLock ¶
func WithTxLock(mode TxLockMode) Option
WithTxLock sets liustack/sqlite's _txlock, overriding the DSN value. Read-only transactions always begin deferred.
func WithWALLimit ¶
WithWALLimit sets liustack/sqlite's _wal_limit in bytes, overriding the DSN value. Above this threshold the driver tries to restart the WAL. Zero turns off this size-based restart. It takes effect only in WAL mode.
type TxLockMode ¶
type TxLockMode string
TxLockMode controls how SQLite begins write transactions.
const ( // TxDeferred waits until the first write before acquiring a write lock. TxDeferred TxLockMode = "deferred" // TxImmediate acquires the write lock at BEGIN. TxImmediate TxLockMode = "immediate" // TxExclusive acquires the write lock at BEGIN and blocks readers outside WAL mode. TxExclusive TxLockMode = "exclusive" )
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
quickstart
command
|
|
|
Package sqlite3 registers liustack/sqlite under the name Ent uses for the SQLite dialect.
|
Package sqlite3 registers liustack/sqlite under the name Ent uses for the SQLite dialect. |