[Django]-SQLAlchemy and django, is it production ready?

20đź‘Ť

âś…

What I would do,

  1. Define the schema in Django orm, let it write the db via syncdb. You get the admin interface.

  2. 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, ...)

👤agiliq

8đź‘Ť

I don’t think it’s good practice to use both. You should either:

  1. Use Django’s ORM and use custom SQL where Django’s built-in SQL generation doesn’t meet your needs, or
  2. Use SQLAlchemy (which gives you finer control at the price of added complexity).

Of course, if you need Django’s admin, then the first of these approaches is recommended.

👤Vinay Sajip

8đź‘Ť

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.

👤Stuart Axon

5đź‘Ť

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.

4đź‘Ť

Nowadays you can use Aldjemy. Consider using this tutorial.

👤Mathieu Rodic

Leave a comment