Comparing different methods of rolling back database changes in pytest tests for SQLAlchemy

I'm working on a project that uses FastAPI and SQL Alchemy asynchronously.
I've written pytest tests for this project and have successfully implemented database rollback after each test run.
I've found two different implementation methods, but I'm unsure about the differences between them. Are both methods correct, or is one potentially problematic?

Thanks for reaching out. Can you provide some more context about the problem you are facing? Is this an Elastic issue?