> Create an empty schema from the models using create_all? 

This is what I usually do with smaller projects.  On some large legacy 
projects, I use a database dump that is loaded into Postgres - as they 
often rely on a lot of records that need to be in the database and 
generating them via SqlAlchemy is so much slower and would be a pain to 
develop.

When using unittest, some tests will use a fresh DB per test-run, others 
per-class, and others per-test.  Sometimes the tests dictate that, other 
times I control that with env vars.  That gives us the flexibility to work 
on a small section and do efficient test runs during development.

On Wednesday, August 31, 2022 at 6:02:29 PM UTC-4 Chris Withers wrote:

> Hi All,
>
> Are there any libraries (or anything in sqlalchemy itself!) that cover 
> the pattern of running unit tests in against a database such that each 
> test gets its own sterile environment in which to run? Postgres, if it 
> helps. I've done some stuff with running in a subtransaction and rolling 
> back at the end of the test before, but wanted to see if anything had 
> become common enough to end up in a popular library yet...
>
> What's the recommended way of getting a blank db to test against? Run 
> alembic migrations in a session-level fixture? Create an empty schema 
> from the models using create_all? Something else?
>
> cheers,
>
> Chris
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/dc72a5f3-794f-43e7-b3aa-f0a2ec2a9028n%40googlegroups.com.

Reply via email to