pub fn convert_table_to_jsonb(
conn: &Connection,
table: &str,
) -> Result<Vec<(String, Value)>>Expand description
Convert an entire SQLite table to JSONB format
Reads all rows from a SQLite table and converts them to JSONB. Returns a vector of (id, json_data) tuples ready for insertion.
§ID Generation Strategy
- If table has a column named “id”, “rowid”, or “_id”, use that as the ID
- Otherwise, use SQLite’s rowid (every table has one)
- IDs are converted to strings for consistency
§Arguments
conn- SQLite database connectiontable- Table name (must be validated)
§Returns
Vector of (id_string, json_data) tuples for batch insert
§Security
Table name should be validated before calling this function.
§Examples
let conn = open_sqlite("database.db")?;
let table = "users";
validate_table_name(table)?;
let rows = convert_table_to_jsonb(&conn, table)?;
println!("Converted {} rows to JSONB", rows.len());