Function count

Source
pub fn count(sql: &str) -> usize
Expand description

Count statements in a string of sqlite sql

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

This func returns the number of sql statements in an &str. It does some extremely basic parsing of SQL to determine the answer, and calling it will take O(n) time, where n is the length of SQL.

use sql_split::count;

let sql = "CREATE TABLE foo (bar text); CREATE TABLE meep (moop text)";
assert_eq!(count(sql), 2);