fix(database): More robust sql script execution.

Implemented tests for various formats of SQL input and fixed a bug that caused
text inside SQL strings to be interpreted as comments. Specifically, "INSERT
INTO x values ('some string -- not a comment');" is now supported. Also added
support for comments prefixed with "# ".
Merge pull request #7294 from stianlik/1.9

fix(database): More robust sql script execution.