How to Use SQLite with Rust

Complete Guide

Embed SQLite in Rust by enabling the sqlite and libsqlite3-sys/bundled features in the diesel crate.

Use the diesel crate with the sqlite and libsqlite3-sys/bundled features to embed SQLite directly into your Rust binary without external dependencies. Add diesel = { version = "2.2", features = ["sqlite", "libsqlite3-sys/bundled"] } to your Cargo.toml and run cargo build to compile the database engine alongside your application.

[dependencies]
diesel = { version = "2.2", features = ["sqlite", "libsqlite3-sys/bundled"] }

This configuration ensures SQLite is compiled as part of the build process, matching the setup used in the diesel test suite where features: Some(&["sqlite", "libsqlite3-sys/bundled"]) is specified.