stringqb/src/drivers/mod.rs

42 lines
986 B
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;
#[cfg(feature="pg")]
mod postgres;
#[cfg(feature="sqlite")]
mod sqlite;
#[derive(Debug)]
struct Connection;
#[derive(Debug)]
struct QueryResult;
/// 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<(), ()>;
}