8 releases

0.1.3-alpha.5 Jul 22, 2023
0.1.3-alpha.4 Jul 16, 2023
0.1.2 Apr 26, 2023
0.1.1 Mar 12, 2023
0.1.0 Mar 11, 2023

#1797 in Database interfaces

Download history 1/week @ 2023-12-11 40/week @ 2023-12-18 33/week @ 2023-12-25 45/week @ 2024-01-22 312/week @ 2024-01-29 41/week @ 2024-02-12 182/week @ 2024-02-19 139/week @ 2024-02-26 83/week @ 2024-03-04 77/week @ 2024-03-11 123/week @ 2024-03-18

424 downloads per month
Used in 2 crates (via teo-sql-connector)

Apache-2.0

1MB
21K SLoC

Quaint

docs.rs Cargo tests Discord

Notice

This project is a fork of Prisma's quaint.

Introduction

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

  • mysql: Support for MySQL databases.
  • postgresql: Support for PostgreSQL databases.
  • sqlite: Support for SQLite databases.
  • mssql: Support for Microsoft SQL Server databases.
  • pooled: A connection pool in pooled::Quaint.
  • json: JSON type support with serde_json crate.
  • uuid: UUID type support with uuid crate.
  • chrono: DateTime type support with chrono crate.
  • serde-support: Deserialize support from result set with serde crate.
  • bigdecimal: Numeric values can be read as BigDecimal.
  • vendored-openssl: Statically links against a vendored OpenSSL library on non-Windows or non-Apple platforms.
  • fmt-sql: Enables logging SQL queries formatted. The FMT_SQL env var must be present for the formatting to be enabled.

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.

The FMT_SQL environment variable can be used to log formatted SQL queries. Beware, the fmt-sql feature must be enabled too.

Security

If you have a security issue to report, please contact us at security@prisma.io

Dependencies

~4–26MB
~423K SLoC