1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use cdbc::connection::ConnectOptions;
use cdbc::error::Error;
use cdbc::executor::Executor;
use crate::connection::establish::establish;
use crate::{SqliteConnectOptions, SqliteConnection};
use std::time::Duration;
impl ConnectOptions for SqliteConnectOptions {
type Connection = SqliteConnection;
fn connect(&self) -> Result<Self::Connection, Error>
where
Self::Connection: Sized,
{
let mut conn = establish(self)?;
let mut init = String::new();
for (key, value) in self.pragmas.iter() {
use std::fmt::Write;
write!(init, "PRAGMA {} = {}; ", key, value).ok();
}
conn.execute(&*init)?;
Ok(conn)
}
}