SQLite Forum

Internal schema cache not refreshed after DROP TABLE in different connection
Login
Can you print [1] and [2] at various points in your program too?  
Also try w/o WAL IMHO. And with WAL, perhaps force a WAL checkpoint, to see what happens.

[1] https://www.sqlite.org/pragma.html#pragma_schema_version  
[2] https://www.sqlite.org/pragma.html#pragma_data_version