stringqb/src/drivers/mod.rs

50 lines
1.1 KiB
Rust
Raw Normal View History

2019-04-02 16:35:52 -04:00
//! Drivers
//!
//! Drivers represent a connection to a specific type of database engine
use std::fmt;
2019-04-04 16:39:05 -04:00
#[cfg(feature = "postgres")]
2019-04-02 16:35:52 -04:00
mod postgres;
2019-04-04 16:39:05 -04:00
#[cfg(feature = "sqlite")]
2019-04-02 16:35:52 -04:00
mod sqlite;
2019-04-04 16:39:05 -04:00
#[cfg(feature = "mysql")]
2019-04-03 20:58:22 -04:00
mod mysql;
2019-04-02 16:35:52 -04:00
#[derive(Debug)]
struct Connection;
2019-04-03 20:58:22 -04:00
/// Result for a db query
2019-04-02 16:35:52 -04:00
#[derive(Debug)]
struct QueryResult;
2019-04-04 16:39:05 -04:00
struct DriverBase {
escape_char_open: char,
escape_char_close: char,
has_truncate: bool,
}
2019-04-02 16:35:52 -04:00
/// Database Driver Trait
///
/// Interface between the database connection library and the query builder
pub trait DatabaseDriver: fmt::Debug {
2019-04-03 16:29:51 -04:00
/// Vector version of `quote_identifier`
fn quote_identifiers(&self, identifiers: Vec<String>) -> Vec<String> {
let mut output: Vec<String> = vec![];
for identifier in identifiers {
output.push(self.quote_identifier(&identifier));
}
output
}
/// Quote the identifiers passed, so the database does not
/// normalize the identifiers (eg, table, column, etc.)
fn quote_identifier(&self, identifier: &str) -> String;
2019-04-02 16:35:52 -04:00
/// Runs a basic sql query on the database
fn query(&self, query: &str) -> Result<(), ()>;
}