prepare: throw exception instead of assertion

There are cases where you may want to be able to recover from a failure
to prepare a statement. As an example, the prepare may fail because it
uses a foreign data table that Sqlite is currently unaware of. By
throwing an exception, it is possible to recover from the failure,
update the db and retry.

Reviewed-by: srhea@meraki.com