Has anyone used SQLAlchemy
in addition to Django
\'s ORM?
I\'d like to use Django\'s ORM for object manipulation and SQLalchemy for complex
Jacob Kaplan-Moss admitted to typing "import sqlalchemy" from time to time. I may write a queryset adapter for sqlalchemy results in the not too distant future.
Nowadays you can use Aldjemy. Consider using this tutorial.
I don't think it's good practice to use both. You should either:
Of course, if you need Django's admin, then the first of these approaches is recommended.
I've done it before and it's fine. Use the SQLAlchemy feature where it can read in the schema so you don't need to declare your fields twice.
You can grab the connection settings from the settings, the only problem is stuff like the different flavours of postgres driver (e.g. with psyco and without).
It's worth it as the SQLAlchemy stuff is just so much nicer for stuff like joins.
What I would do,
Define the schema in Django orm, let it write the db via syncdb. You get the admin interface.
In view1 you need a complex join
def view1(request):
import sqlalchemy
data = sqlalchemy.complex_join_magic(...)
...
payload = {'data': data, ...}
return render_to_response('template', payload, ...)