Debian Codegraph @

third_party/rust/rusqlite/examples/load_extension.rs

raw
1 //! Ensure `loadable_extension.rs` works.
2
3 use rusqlite::{Connection, Result};
4 use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
5
6 fn main() -> Result<()> {
7 let db = Connection::open_in_memory()?;
8
9 unsafe {
10 db.load_extension_enable()?;
11 db.load_extension(
12 format!("target/debug/examples/{DLL_PREFIX}loadable_extension{DLL_SUFFIX}"),
13 None,
14 )?;
15 db.load_extension_disable()?;
16 }
17
18 let str = db.query_row("SELECT rusqlite_test_function()", [], |row| {
19 row.get::<_, String>(0)
20 })?;
21 assert_eq!(&str, "Rusqlite extension loaded correctly!");
22 Ok(())
23 }