Pyramid SQLAlchemy database changes disappear on reload
I just started building my webapp, working from the pyramid tutorials.
When I add an item to my database, it gets persisted correctly, but when I change something in pyramid and need to restart the server
$VENV/bin/pserve development.ini --reload
all my changes are lost. Does anyone know why this happens?
I changed the initialize_db.py script to build a demo database, and changed the sessionmaker to
session = scoped_session(sessionmaker(extension=ZopeTransactionExtension('changed')))
I've tried session.commit() and session.flush(), with no luck.
You're supposed to also have the pyramid_tm (transaction manager) configured; it is the one that actually commits the changes. Now it seems like you're not committing the changes / are just reusing the same dirty uncommitted session from request to another.
In any case, make sure that the development.ini that you're using contains
pyramid.includes = pyramid_debugtoolbar pyramid_tm <--- this here