de.theappguys.winzigsql
Class SqlUtils

java.lang.Object
  extended by de.theappguys.winzigsql.SqlUtils

public class SqlUtils
extends Object

Util methods for sql execution and parsing.


Method Summary
static void executeStatements(android.database.sqlite.SQLiteDatabase db, Iterable<String> sqlStatements)
          Executes all given statements on the given db.
static void executeStatements(android.database.sqlite.SQLiteDatabase db, String sqlStatements)
          Executes all statements in the given string using the comment-aware script parser implemented by parseSqlScript
static List<String> parseSqlScript(String script)
          Poor man's sql script parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseSqlScript

public static List<String> parseSqlScript(String script)
Poor man's sql script parser. Slightly more powerful than the Android built-in parser as it allows c-style block comments and one line comments. Assumes all statements are terminated by a semicolon at the end of a line. Two hyphens are always regarded as the beginning of a comment, a slash / and asterisk * are always regarded as the beginning of a block comment, so they cannot be used in string values (TODO: better parsing of string literals is necessary). Block comments are removed before line comments, so line comments do not "hide" the start or end of a block comment.


executeStatements

public static void executeStatements(android.database.sqlite.SQLiteDatabase db,
                                     String sqlStatements)
Executes all statements in the given string using the comment-aware script parser implemented by parseSqlScript


executeStatements

public static void executeStatements(android.database.sqlite.SQLiteDatabase db,
                                     Iterable<String> sqlStatements)
Executes all given statements on the given db. Statements are expected to have no comments in them and each be placed in a single string.



Copyright © 2013. All Rights Reserved.