Skip to main content

Crate sqlite

Crate sqlite 

Source
Available on crate feature _sqlite only.
Expand description

SQLite database driver.

§Note: libsqlite3-sys Version

This driver uses the libsqlite3-sys crate which links the native library for SQLite 3. Only one version of libsqlite3-sys may appear in the dependency tree of your project.

As of SQLx 0.9.0, the version of libsqlite3-sys is now a range instead of any specific version. See the Cargo.toml of the sqlx-sqlite crate for the current version range.

If you are using rusqlite or any other crate that indirectly depends on libsqlite3-sys, this should allow Cargo to select a compatible version.

If Cargo fails to select a compatible version, this means the other crate is using a libsqlite3-sys version outside of this range.

We may increase the maximum version of the range at our discretion, in patch (SemVer-compatible) releases, to allow users to upgrade to newer versions as desired.

The minimum version of the range may be increased over time to drop very old or insecure versions of SQLite, but this will only occur in major (SemVer-incompatible) releases.

Note that this means a cargo update may increase the libsqlite3-sys version, which could, in rare cases, break your build.

To prevent this, you can pin the libsqlite3-sys version in your own dependencies:

[dependencies]
# for example, if 0.35.0 breaks the build
libsqlite3-sys = "0.34"

§Static Linking (Default)

The sqlite feature enables the bundled feature of libsqlite3-sys, which builds SQLite 3 from included source code and statically links it into the final binary.

This requires some C build tools to be installed on the system; see the rusqlite README for details.

This version of SQLite is generally much newer than system-installed versions of SQLite (especially for LTS Linux distributions), and can be updated with a cargo update, so this is the recommended option for ease of use and keeping up-to-date.

§Dynamic linking

To dynamically link to an existing SQLite library, the sqlite-unbundled feature can be used instead.

This allows updating SQLite independently of SQLx or using forked versions, but you must have SQLite installed on the system or provide a path to the library at build time (see the rusqlite README for details).

Note that this may result in link errors if the SQLite version is too old, or has certain features disabled at compile-time.

SQLite version 3.20.0 (released August 2018) or newer is recommended.

Please check your SQLite version and the flags it was built with before opening a GitHub issue because of errors in libsqlite3-sys. Thank you.

§Optional Features

The following features

Modules§

anyany
types
Conversions between Rust and SQLite types.

Structs§

LockedSqliteHandle
PreupdateHookResult
Sqlite
Sqlite database driver.
SqliteArguments
SqliteArgumentsBuffer
SqliteColumn
SqliteConnectOptions
Options and flags which can be used to configure a SQLite connection.
SqliteConnection
A connection to an open Sqlite database.
SqliteError
SqliteOwnedBuf
Memory buffer owned and allocated by SQLite. Freed on drop.
SqliteQueryResult
SqliteRow
Implementation of Row for SQLite.
SqliteStatement
SqliteTransactionManager
Implementation of TransactionManager for SQLite.
SqliteTypeInfo
Type information for a SQLite type.
SqliteValue
An owned handle to a sqlite3_value.
SqliteValueRef
A borrowed reference to a sqlite3_value.
UpdateHookResult

Enums§

SqliteArgumentValue
SqliteAutoVacuum
SqliteJournalMode
Refer to SQLite documentation for the meaning of the database journaling mode.
SqliteLockingMode
Refer to SQLite documentation for the meaning of the connection locking mode.
SqliteOperation
SqliteSynchronous
Refer to SQLite documentation for the meaning of various synchronous settings.

Traits§

SqliteExecutor
An alias for Executor<'_, Database = Sqlite>.

Type Aliases§

SqlitePool
An alias for Pool, specialized for SQLite.
SqlitePoolOptions
An alias for PoolOptions, specialized for SQLite.
SqliteTransaction
An alias for Transaction, specialized for SQLite.