Follow the design pattern that Django uses.
Create a one-time copy of the database. For example, use SQLite3 in memory.
Create the database using SQLAlchemy tables and index definitions. This should be a pretty trivial exercise.
Download the test database to the database.
Run your unit test case in a database with a known, specific state.
Dispose of the database.
If you are using SQLite3 in memory, this procedure can be quite fast.
source share