SQLAlchemy 和 django,生产准备好了吗? [英] SQLAlchemy and django, is it production ready?

查看:22
本文介绍了SQLAlchemy 和 django,生产准备好了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了 Django 的 ORM 之外,有人用过 SQLAlchemy 吗?

我想使用 Django 的 ORM 进行对象操作,使用 SQLalchemy 进行复杂查询(例如需要左外连接的查询).

有可能吗?

注意:我知道 django-sqlalchemy 但该项目似乎还没有准备好投入生产.

解决方案

我会怎么做,

  1. 在Django orm中定义schema,让它通过syncdb写入db.您将获得管理界面.

  2. 在view1中你需要一个复杂的join

<前><代码>定义视图1(请求):导入 sqlalchemy数据 = sqlalchemy.complex_join_magic(...)...有效载荷 = {'数据':数据,...}return render_to_response('模板',有效载荷,...)

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 queries (like those that require left outer joins).

Is it possible?

Note: I'm aware about django-sqlalchemy but the project doesn't seem to be production ready.

解决方案

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

这篇关于SQLAlchemy 和 django,生产准备好了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆