27 releases

0.2.0-alpha.13 Jun 16, 2020
0.2.0-alpha.12 May 20, 2020
0.2.0-alpha.11 Mar 26, 2020
0.2.0-alpha.9 Feb 28, 2020
0.1.4 Dec 30, 2019

#55 in Database interfaces

Download history 33/week @ 2020-04-24 9/week @ 2020-05-01 184/week @ 2020-05-08 137/week @ 2020-05-15 40/week @ 2020-05-22 72/week @ 2020-05-29 44/week @ 2020-06-05 26/week @ 2020-06-12 6/week @ 2020-06-19 5/week @ 2020-06-26 72/week @ 2020-07-03 56/week @ 2020-07-10 77/week @ 2020-07-17 34/week @ 2020-07-24 8/week @ 2020-07-31 35/week @ 2020-08-07

339 downloads per month

Apache-2.0

550KB
12K SLoC

Quaint

crates.io docs.rs Build status Discord

Quaint is an abstraction over certain SQL databases. It provides:

  • An AST for building dynamic SQL queries.
  • Visitors for different databases to generate SQL strings.
  • Connectors to abstract over results and querying.
  • Pooling with mobc
  • Async/await and Futures 0.3

Documentation

Feature flags

  • full: All connectors and a pooled Quaint manager
  • full-postgresql: Pooled support for PostgreSQL
  • full-mysql: Pooled support for MySQL
  • full-sqlite: Pooled support for SQLite
  • full-mssql: Pooled support for Microsoft SQL Server
  • single: All connectors, but no pooling
  • single-postgresql: Single connection support for PostgreSQL
  • single-mysql: Single connection support for MySQL
  • single-sqlite: Single connection support for SQLite
  • single-mssql: Single connection support for Microsoft SQL Server

Goals:

  • Query generation when the database and conditions are not known beforehand.
  • Parameterized queries and SQL injection protection.
  • A modular design, a separate AST and separate visitors and connectors.

Non-goals:

  • Database-level type-safety in query building or being an ORM.

For type-safe database abstraction, Diesel is an excellent choice.

Testing:

  • See .envrc for connection params. Override variables if different. MySQL, PostgreSQL and SQL Server needs to be running for tests to succeed.

Then:

> cargo test

Query debug

The queries can be logged by setting the LOG_QUERIES environment variable to any value. They'll be logged at the INFO level and are visible when having a logger in scope. If using Tracing, compiling Quaint with the tracing-log feature flag will parameterize the logged queries into a more suitable format for Tracing.

Dependencies

~3–9MB
~188K SLoC