Added set_sqlite3_error() to database.c.

DRY out code to free previous error and set new one.