split_n

Function split_n 

Source
pub fn split_n(sql: &str, n: Option<usize>) -> Vec<String>
Expand description

Split first N statements from a multi-statement sql string into a Vec

SQL is an &str containing some sql statements separated by semicolons.

N is an Option. If None, returns all statements, otherwise up to N statements.

use sql_split::split_n;
use rusqlite::{Connection, Result};

let sql = "CREATE TABLE foo (bar text); CREATE TABLE meep (moop text)";
assert_eq!(split_n(sql, Some(1)), vec!["CREATE TABLE foo (bar text);"]);