pub fn open<P: AsRef<Path>>(path: P, flags: OpenFlags, config: &Object) -> Result<Connection> {
    // once: load libgenomicsqlite extension
    START.call_once(|| {
        let mut _tmpdir;
        let libgenomicsqlite = match env::var("LIBGENOMICSQLITE") {
            Ok(v) => v,
            Err(_) => match bundle_libgenomicsqlite() {
                Some((ans, td)) => {
                    _tmpdir = td;
                    ans
                }
                None => "libgenomicsqlite".to_string(),
            },
        };
        let memconn = Connection::open_in_memory().unwrap();
        let _guard = LoadExtensionGuard::new(&memconn).unwrap();
        match memconn.load_extension(libgenomicsqlite.clone(), None) {
            Err(err) => panic!(
                "genomicsqlite failed to load_extension(\"{}\"): {}",
                libgenomicsqlite, err
            ),
            Ok(()) => (),
        }
    });

    // generate config & connection strings
    let memconn = Connection::open_in_memory().unwrap();
    let config_json_str = config.dump();
    let uri: String = query1str(
        &memconn,
        "SELECT genomicsqlite_uri(?,?)",
        params![path.as_ref().to_str().unwrap(), &config_json_str],
    )?;

    // open GenomicSQLite connection
    let conn = Connection::open_with_flags(uri, flags | OpenFlags::SQLITE_OPEN_URI)?;

    // generate and execute tuning SQL script
    let tuning_sql = query1str(
        &conn,
        "SELECT genomicsqlite_tuning_sql(?)",
        params![&config_json_str],
    )?;
    conn.execute_batch(&tuning_sql)?;

    Ok(conn)
}
/// Open a [rusqlite::Connection] for a compressed database with the [ConnectionMethods] available.
///
/// # Arguments
///
/// * `path` - Database filename
/// * `flags` - SQLite open mode flags, as in [rusqlite::Connection::open_with_flags]
/// * `config` - [GenomicSQLite tuning options](https://mlin.github.io/GenomicSQLite/guide/#tuning-options),
///              as JSON keys & values; may be empty `Object::new()` to use defaults
///
/// # Examples
///
/// ```
/// use genomicsqlite::ConnectionMethods;
/// let conn = genomicsqlite::open(
///     "/tmp/rustdoc_example.genomicsqlite",
///     rusqlite::OpenFlags::SQLITE_OPEN_CREATE | rusqlite::OpenFlags::SQLITE_OPEN_READ_WRITE,
///     &json::object::Object::new()
/// );
/// println!("GenomicSQLite {}", conn.unwrap().genomicsqlite_version());
/// ```
Open a [rusqlite::Connection] for a compressed database with the [ConnectionMethods] available.
Open a [ rusqlite :: Connection ] for a compressed database with the [ ConnectionMethods ] available .
pub fn open<P: AsRef<Path>>(path: P, flags: OpenFlags, config: &Object) -> Result<Connection> {
    // once: load libgenomicsqlite extension
    START.call_once(|| {
        let mut _tmpdir;
        let libgenomicsqlite = match env::var("LIBGENOMICSQLITE") {
            Ok(v) => v,
            Err(_) => match bundle_libgenomicsqlite() {
                Some((ans, td)) => {
                    _tmpdir = td;
                    ans
                }
                None => "libgenomicsqlite".to_string(),
            },
        };
        let memconn = Connection::open_in_memory().unwrap();
        let _guard = LoadExtensionGuard::new(&memconn).unwrap();
        match memconn.load_extension(libgenomicsqlite.clone(), None) {
            Err(err) => panic!(
                "genomicsqlite failed to load_extension(\"{}\"): {}",
                libgenomicsqlite, err
            ),
            Ok(()) => (),
        }
    });
    // generate config & connection strings
    let memconn = Connection::open_in_memory().unwrap();
    let config_json_str = config.dump();
    let uri: String = query1str(
        &memconn,
        "SELECT genomicsqlite_uri(?,?)",
        params![path.as_ref().to_str().unwrap(), &config_json_str],
    )?;
    // open GenomicSQLite connection
    let conn = Connection::open_with_flags(uri, flags | OpenFlags::SQLITE_OPEN_URI)?;
    // generate and execute tuning SQL script
    let tuning_sql = query1str(
        &conn,
        "SELECT genomicsqlite_tuning_sql(?)",
        params![&config_json_str],
    )?;
    conn.execute_batch(&tuning_sql)?;
    Ok(conn)
}
pub fn open < P : AsRef < Path > > ( path : P , flags : OpenFlags , config : & Object ) -> Result < Connection > { // once: load libgenomicsqlite extension START . call_once ( | | { let mut _tmpdir ; let libgenomicsqlite = match env :: var ( " " ) { Ok ( v ) => v , Err ( _ ) => match bundle_libgenomicsqlite ( ) { Some ( ( ans , td ) ) => { _tmpdir = td ; ans } None => " " . to_string ( ) , } , } ; let memconn = Connection :: open_in_memory ( ) . unwrap ( ) ; let _guard = LoadExtensionGuard :: new ( & memconn ) . unwrap ( ) ; match memconn . load_extension ( libgenomicsqlite . clone ( ) , None ) { Err ( err ) => panic ! ( " \" \" " libgenomicsqlite err ) , Ok ( ( ) ) => ( ) , } } ) ; // generate config & connection strings let memconn = Connection :: open_in_memory ( ) . unwrap ( ) ; let config_json_str = config . dump ( ) ; let uri : String = query1str ( & memconn , " " , params ! [ path as_ref ( ) to_str ( ) unwrap ( ) config_json_str ] , ) ? ; // open GenomicSQLite connection let conn = Connection :: open_with_flags ( uri , flags | OpenFlags :: SQLITE_OPEN_URI ) ? ; // generate and execute tuning SQL script let tuning_sql = query1str ( & conn , " " , params ! [ config_json_str ] , ) ? ; conn . execute_batch ( & tuning_sql ) ? ; Ok ( conn ) }
Open a [rusqlite::Connection] for a compressed database with the [ConnectionMethods] available.
Open a [ rusqlite :: Connection ] for a compressed database with the [ ConnectionMethods ] available .
path
P
flags
OpenFlags
config
&Object
path
P
flags
OpenFlags
config
&Object
examples
```
use genomicsqlite::ConnectionMethods;
let conn = genomicsqlite::open(
"/tmp/rustdoc_example.genomicsqlite",
rusqlite::OpenFlags::SQLITE_OPEN_CREATE | rusqlite::OpenFlags::SQLITE_OPEN_READ_WRITE,
&json::object::Object::new()
);
println!("GenomicSQLite {}", conn.unwrap().genomicsqlite_version());
```
` ` ` use genomicsqlite :: ConnectionMethods ; let conn = genomicsqlite :: open ( " / tmp / rustdoc_example . genomicsqlite " rusqlite :: OpenFlags :: SQLITE_OPEN_CREATE | rusqlite :: OpenFlags :: SQLITE_OPEN_READ_WRITE &json :: object :: Object :: new () ) ; println! ( " GenomicSQLite {} " conn . unwrap () . genomicsqlite_version () ) ; ` ` `