Fixed some SQLite bugs when the database is empty.