qusql-sqlx-type
Proc macros to perform typed SQL queries on top of sqlx
for PostgreSQL, MySQL/MariaDB, and (to a lesser extent) SQLite, without the need to run
cargo sqlx prepare or have a running database during cargo check.
A schema definition must be placed in sqlx-type-schema.sql in the root of a using crate:
IF EXISTS `t1`;
(
`id` int(11) NOT NULL,
`cbool` tinyint(1) NOT NULL,
`cu8` tinyint UNSIGNED NOT NULL,
`cu16` smallint UNSIGNED NOT NULL,
`cu32` int UNSIGNED NOT NULL,
`cu64` bigint UNSIGNED NOT NULL,
`ci8` tinyint,
`ci16` smallint,
`ci32` int,
`ci64` bigint,
`ctext` varchar(100) NOT NULL,
`cbytes` blob,
`cf32` float,
`cf64` double
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
`t1`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
See qusql_type::schema for a detailed description of supported schema syntax.
This schema can then be used to type queries:
use ;
async
See also the examples:
examples/qusql-sqlx-type-notes- simple introductory CLI (single-table schema)examples/qusql-sqlx-type-books- library catalog with JOINs, enums, UUIDs, dates, and an idempotent migration pattern