Closed dshum closed 6 months ago
Apologies, this hasn't been on my radar since I've been using autocommit_before_send_handler
from advanced_alchemy
https://github.com/jolt-org/advanced-alchemy/blob/main/advanced_alchemy/extensions/litestar/plugins/init/config/asyncio.py#L111
In short, that will commit the current transaction if the status code is 2xx, else rollback.
litestar-users should probably have a way to set the autocommit
attribute on the repository.
You mean, add it to SQLAlchemyAsyncConfig?
db_config = SQLAlchemyAsyncConfig(
...
before_send_handler=autocommit_before_send_handler,
)
Thanks for the hint, this will do.
If you run the code in the examples, the user's changes are not saved in the database. Should I use session.commit() or auto_commit=True myself, and where exactly?