Andrei Berenda
Andrei Berenda

Reputation: 1986

SQLAchemy and Django

Is there a some way to do the same thing like prefetch_related in DjangoORM in SQLAlchemy?

I have models like this:

class User(...):
    regions  = models.ManyToMany(Region)
    name = models.CharField(...)

class Region(...): 
    title = models.CharField(...)

And I have the same classes for sql alchemy.

And I want to rewrite the code in sql alchemy:

name = 'Lucas'
users = User.objects.filter(name=name).prefetch_related('regions')

Upvotes: 1

Views: 135

Answers (1)

Jason
Jason

Reputation: 11363

not without significant difficulty. the default django ORM is very tightly integrated and replacing it with SQLAlchemy is a non-trivial task.

https://github.com/Deepwalker/aldjemy suggests it can help with this.

Upvotes: 1

Related Questions