39 lines
826 B
Rust
39 lines
826 B
Rust
//! Database Driver for SQLite
|
|
//!
|
|
//! Use of this driver requires enabling the `sqlite` feature.
|
|
//!
|
|
//! Contains database-specific query data
|
|
use super::*;
|
|
|
|
use slite::{Connection};
|
|
use std::cell::RefCell;
|
|
|
|
/// The struct implementing the `DatabaseDriver` trait
|
|
#[derive(Debug)]
|
|
pub struct SQLiteDriver {
|
|
connection: RefCell<Option<Connection>>
|
|
}
|
|
|
|
impl SQLiteDriver {
|
|
/// Create an SQLiteDriver driver
|
|
pub fn new() -> Self {
|
|
SQLiteDriver {
|
|
connection: RefCell::new(None)
|
|
}
|
|
}
|
|
}
|
|
|
|
impl DatabaseDriver for SQLiteDriver {
|
|
// fn query(&self, sql: &str) -> Result<(), ()> {
|
|
// unimplemented!();
|
|
// }
|
|
|
|
fn explain(&self, sql: &str) -> String {
|
|
format!("EXPLAIN QUERY PLAN {}", sql)
|
|
}
|
|
|
|
fn random(&self) -> String {
|
|
String::from(" RANDOM()")
|
|
}
|
|
}
|