You can search ahead for either end-of-string or a semicolon. If you find a semicolon, then you also need to check that you have a complete SQL statement using the [sqlite3_complete()][1] interface, because otherwise the semicolon you found might be in the middle of a string literal or a trigger. [1]: https://www.sqlite.org/c3ref/complete.html