stringqb/src/lib.rs

66 lines
1.8 KiB
Rust

//! # StringQB
//!
//! A query builder using mostly strings, with methods following common SQL syntax
//!
//! Drivers include:
//! * `PostgresDriver` - for PostgreSQL databases
//! * `MySQLDriver` - for MySQL/MariaDB databases
//! * `SQLiteDriver` - for SQLite databases
//!
//! Example:
//! ```no_run
//! use stringqb::prelude::*;
//!
//! // Create the database driver object (Postgres is enabled by default)
//! let pgDriver = PostgresDriver::new("postgres://user:pass@host:port/database");
//!
//! // The query builder must be mutable to be useful
//! let mut qb = QueryBuilder::new(pgDriver);
//!
//! // Each builder method returns a mutable reference to itself so
//! // the methods are chainable
//! qb.select("field as f")
//! .from("table t")
//! .inner_join("table_two tt", "field2 as ff", "=", "f")
//! .wher("f >", 3);
//!
//! // Since they are references, you do not have to chain.
//! let sql = qb.get_compiled_select();
//! ```
#![warn(missing_docs)]
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "sqlite")]
#[macro_use]
extern crate slite;
pub mod drivers;
pub mod fns;
pub mod query_builder;
pub mod types;
pub mod prelude {
//! Re-exports important traits and types.
//!
//! This includes enum types, traits,
//! the Query Builder, and individual database drivers.
pub use crate::drivers::DatabaseDriver;
pub use crate::query_builder::{JoinType, LikeWildcard, OrderDirection, QueryBuilder};
#[cfg(feature = "postgres")]
/// Postgres Driver
pub use crate::drivers::postgres::PostgresDriver;
#[cfg(feature = "sqlite")]
/// SQLite Driver
pub use crate::drivers::sqlite::SQLiteDriver;
#[cfg(feature = "mysql")]
/// MySQL Driver
pub use crate::drivers::mysql::MySQLDriver;
// MSSQL is missing on purpose, as it is not a real priority to actually implement
}