Is Tortoise ORM Ready for Production Use?
Asked by
CuriousCat42
I'm exploring the possibility of using Tortoise ORM for my project because it seems easier to handle async database operations compared to SQLAlchemy. Plus, it has native support for FastAPI, which is a bonus. Has anyone actually used Tortoise ORM in a production environment? I'd love to hear your thoughts and experiences!
Answers
Honestly, I think SQLAlchemy isnโt that complicated to test. You can easily reconfigure your sessionmaker to point to a new engine. If your engine isn't referenced directly in the app, youโre golden! Alternatively, wrapping the engine in a container object for easier overrides is also an option.
Reply to this answer
I've been using Tortoise ORM in a production environment for a couple of years now, primarily because SQLAlchemy was slow to implement async support. While the core features of Tortoise are pretty solid, the integration with FastAPI and Pydantic has its quirks, although it's not essential. Donโt overlook the Tortoise migration tool; itโs quite handy even if it lags behind Alembic.
Reply to this answer
What makes Tortoise ORM easier to test? Personally, I find Django's DB-connected testing annoying, but since I switched to Testcontainers, itโs not so bad. SQLAlchemy seems to keep the domain cleaner and can often be tested without direct I/O, which is a huge plus.
Reply to this answer
From what Iโve seen, SQLAlchemy is pretty test-friendly. If you're having trouble, you might need to reevaluate your setup.
Reply to this answer
If you're exploring options, give Piccolo ORM a look! Itโs been my preference for most projects lately. Definitely worth checking out!
CritiqueMaster: I checked it out, but it feels like another ORM that doesnโt align with Python basics. We really need to do better in the community!
Reply to this answer
I didn't even know there were other ORMs besides SQLAlchemy! My team's been using SQLAlchemy and Alembic with solid test coverage, so Iโm not quite sure what you mean by it being hard to test. We use PostgreSQL in a Docker container for our tests, which keeps things isolated and runs smoothly. Sure, some people really dislike ORMs, but honestly, SQLAlchemy is pretty battle-tested in professional scenarios. Just my two cents!
DevDude99: Sounds like a solid strategy! Iโm curious if any specific libraries helped with your setup.
Reply to this answer
Just started looking into Tortoise. Seems interesting!
Reply to this answer
Add your answer
Answers are reviewed before publication.
CodeNinja77: Actually, Django does allow you to isolate tests from the database. You just gotta choose the right test class!