Sqlitex
Sqlitex is a sqlite library for rust with compile time guarantees. It also has additional features:
- Ergonomic with excellent IDE support
- Fast. Automatically caches and reuses prepared statements for you
- Supports BLOB and Transactions
- compile time guarantees for complex sql queries such as, CTEs, Window functions, Datetime functions and more
- allows fallback of runtime features when needed
Overview
Installation
Feature showcase
-
Auto generate method signatures with correct types and Hover over to see sql code

(Note: LazyConnection has been renamed to Connection in newer version. library name was previously called LazySql which has now been renamed to Sqlitex)
-
Compile time errors with good error messages



Quick Start
use ;
// Alternatively,
//#[sqlitex("path/to/db.sql")] to point to a .sql file with create table statements.
//#[sqlitex("path/to/existing.db")] to point to an existing database file.
Important note on STRICT tables
It is a common advice to create STRICT tables in sqlite. However, it is recommended not to use it with sqlitex
creating STRICT tables in sqlite will make this library less powerful. STRICT table only allows INT, INTEGER, REAL, TEXT, BLOB, ANY datatypes.
This library offers
- casting as bool
- creating tables with bool data type,
- having slightly more flexible data types (e.g.
REAL,NUMERIC,FLOATare all synonymous).
By enabling STRICT tables you will lose all of these features.
you can read it up more on here or if you are only interested in having compile time checks for boolean using pure sqlite approach
Additional Links
For more examples and features, look at the examples folder and read the documentations.