Hi all, thought I would post this here since this community might find this useful.
I've created a simple python module which can be used to quickly spin up a temporary, disposable postgres server. The main purpose I envisioned for this was for writing tests.
Basically, it works like this:
from pg_temp import TempDB
temp_db = TempDB(databases=['testdb'])
# you can connect to this database using temp_db's pg_socket_dir
connection = psycopg2.connect(host=temp_db.pg_socket_dir, database='testdb')
For many years since using sqlalchemy to abstract the database, I had fallen into the common trap of writing production code targeting postgres, and running unit tests against sqlite, which is a bad idea for many reasons. So I wrote pg-temp so that I'd be able to run unit tests against postgres as easily as I had been doing so against sqlite.
I've been working on it for a couple of years already, so I'd appreciate any feedback or opinions you, the sqlalchemy community, might have. Thanks
Uri