array.rs |
Array Virtual Table.
Note: `rarray`, not `carray` is the name of the table valued function we
define.
Port of [carray](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/carray.c)
C extension: `https://www.sqlite.org/carray.html`
# Example
```rust,no_run
# use rusqlite::{types::Value, Connection, Result, params};
# use std::rc::Rc;
fn example(db: &Connection) -> Result<()> {
// Note: This should be done once (usually when opening the DB).
rusqlite::vtab::array::load_module(&db)?;
let v = [1i64, 2, 3, 4];
// Note: A `Rc<Vec<Value>>` must be used as the parameter.
let values = Rc::new(v.iter().copied().map(Value::from).collect::<Vec<Value>>());
let mut stmt = db.prepare("SELECT value from rarray(?1);")?;
let rows = stmt.query_map([values], |row| row.get::<_, i64>(0))?;
for value in rows {
println!("{}", value?);
}
Ok(())
}
``` |
6283 |
csvtab.rs |
CSV Virtual Table.
Port of [csv](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/csv.c) C
extension: `https://www.sqlite.org/csv.html`
# Example
```rust,no_run
# use rusqlite::{Connection, Result};
fn example() -> Result<()> {
// Note: This should be done once (usually when opening the DB).
let db = Connection::open_in_memory()?;
rusqlite::vtab::csvtab::load_module(&db)?;
// Assume my_csv.csv
let schema = "
CREATE VIRTUAL TABLE my_csv_data
USING csv(filename = 'my_csv.csv')
";
db.execute_batch(schema)?;
// Now the `my_csv_data` (virtual) table can be queried as normal...
Ok(())
}
``` |
12222 |
mod.rs |
Create virtual tables.
Follow these steps to create your own virtual table:
1. Write implementation of [`VTab`] and [`VTabCursor`] traits.
2. Create an instance of the [`Module`] structure specialized for [`VTab`]
impl. from step 1.
3. Register your [`Module`] structure using [`Connection::create_module`].
4. Run a `CREATE VIRTUAL TABLE` command that specifies the new module in the
`USING` clause.
(See [SQLite doc](http://sqlite.org/vtab.html)) |
42654 |
series.rs |
Generate series virtual table.
Port of C [generate series
"function"](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/series.c):
`https://www.sqlite.org/series.html` |
11552 |
vtablog.rs |
Port of C [vtablog](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/vtablog.c) |
8127 |