SurrealDB vs PostgreSQL vs SQLite: Rust database guide

Compare Rust database setups with sqlx and SurrealDB's crate, including compile-time SQL checks, SQLite WAL mode and embedded graph queries.

Player not loading? Watch on YouTube

This comparison explains how PostgreSQL, SQLite and SurrealDB fit different Rust applications, with connection examples and a decision framework. The speaker recommends PostgreSQL for complex relational workloads, SQLite for storage inside a single application, and SurrealDB for projects that combine several data models.

The PostgreSQL example uses sqlx to map rows into Rust structs and check SQL against a database at compile time. It requires a running PostgreSQL instance and migrations or table creation before execution. The SQLite example changes the driver features and stores UUIDs as text. It uses a local database file and WAL mode to allow reads during writes. The speaker identifies write concurrency and scaling beyond one machine as constraints.

The SurrealDB walkthrough starts an in-memory instance inside the Rust process, then explains namespaces, record IDs and RELATE edges with their own metadata. The speaker presents graph traversal, vector search and live queries as reasons to consider it for AI agent memory and related applications, while noting that PostgreSQL has more mature operational tooling.

The video discusses SurrealDB 3.0, but the supplied dependency list specifies the surrealdb 2.x crate alongside sqlx 0.8. Its recommendations are the speaker's assessment of workload fit.