use crate::errors::*; use diesel::{dsl::sql, expression::SqlLiteral, query_dsl::LoadQuery, Connection, RunQueryDsl, SqliteConnection}; pub trait ConnectionExtension: Connection { fn query(&self, query: &str) -> Result where SqlLiteral: LoadQuery; fn exec(&self, query: impl AsRef) -> Result; } impl ConnectionExtension for SqliteConnection { fn query(&self, query: &str) -> Result where SqlLiteral: LoadQuery, { Ok(sql::(query).get_result(self)?) } fn exec(&self, query: impl AsRef) -> Result { Ok(SqliteConnection::execute(self, query.as_ref())?) } }