stringqb/src/drivers/mod.rs

42 lines
986 B
Rust

//! 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 {
/// 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;
/// Runs a basic sql query on the database
fn query(&self, query: &str) -> Result<(), ()>;
}