sql_split

Crates.iosql_split
lib.rssql_split
version0.1.1
sourcesrc
created_at2022-04-26 17:28:15.36373
updated_at2022-04-26 17:29:43.891868
descriptionSplit a string wtih multiple sqlite sql statements into separate strings
homepagehttps://github.com/jvasile/sql_split
repositoryhttps://github.com/jvasile/sql_split
max_upload_size
id575591
size19,753
James Vasile (jvasile)

documentation

https://github.com/jvasile/sql_split

README

sql_split

Split a string into individual sqlite sql statements.

This package is a library that contains some routines for managing multiple sql statements in a string. sqlite silently ignores multiple statements when it only expects one. The popular rusqlite also does this.

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

let conn = Connection::open_in_memory().expect("Can't open db in memory");
let sql = "CREATE TABLE foo (bar text); CREATE TABLE meep (moop text)";
for s in split(sql) {
    conn.execute(&s, []).expect("Can't write to the db");
}

In addition to basic sql statement splitting, there are functions to count the number of statements, a short-cutting function that tries to quickly tell you if you have more than one statement, and a short-cutting function that only tries to split out the first n statements.

License: MIT

Commit count: 35

cargo fmt