njord 0.1.0

A lightweight ORM framework for Rust with strong-typed SQL DSL and sequence APIs.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::env;

use rusqlite::{Connection, Error};

pub mod init;
pub use init::init;
pub mod insert;
pub use insert::insert;

/// Open a database connection
pub fn open(db_name: &str) -> Result<Connection, Error> {
    let target_dir = env::var("OUT_DIR").unwrap_or_else(|_| "../target".to_string());
    let db_file_path = format!("{}/{}", target_dir, &db_name);
    let conn = Connection::open(&db_file_path)?;

    Ok(conn)
}