sqlite3 refactoring