4

觉得 django ORM 和 sqlalchemy 都不太好用

 3 years ago
source link: https://www.v2ex.com/t/817991
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Python

觉得 django ORM 和 sqlalchemy 都不太好用

  wuwukai007 · 15 小时 57 分钟前 · 772 次点击

django

  • 不支持 join group by 关键字 要用 filter 和 values 隐式做到
  • 要用 annotate 才能 取别名,否则还要 extra 写字符串
  • 某些函数不支持,比如 date_format
  • extra 比较灵活,但又不支持 join 😯

sqlalchemy

  • 在 flask 中 使用,会有上下文问题
  • to_dict 还要自己写 ,create 方法没有,必须写 add,commit
  • 写完 sqlalchemy 语句,跟写 sql 感觉没啥区别,

Recommend

  • 10
    • solovyov.net 4 years ago
    • Cache

    Django's ORM#

    Django's ORMНаткнулся тут (спасибо реддиту) на блог замечательного учаснега Адама Гомаа, последний пост которого вещает о том, что Джанговский ОРМ - ме...

  • 10

    写了个基于SQLAlchemy的ORM 2012-02-10 看Rails时,觉得Rails的ORM用起来好方便,就想找找python有没有类似的,没发现太尽如人意的,就按照自己的意愿,基于SQLAlchemy Core重新写了个,取名为Thing,项目主页: “

  • 13
    • blogread.cn 4 years ago
    • Cache

    Django框架ORM操作详解

    Django框架ORM操作详解 浏览:2662次  出处信息 目录1.1.1 生...

  • 7

    V2EX  ›  Python 求教一个 Django 的 ORM 查询怎么写   HashV2 · 2 小时 22 分钟前 · 277 次点击...

  • 9

    V2EX  ›  Python [求助帖] Django ORM 的联表查询问题   lanlanye · 22 分钟前 · 24 次点击

  • 8

    V2EX  ›  Django Django 的 ORM 的 exclude 和 filter 的区别到底是啥?   zhoudaiyu · 16 小...

  • 9
    • blog.ops-coffee.cn 3 years ago
    • Cache

    Django ORM中原生JSONField的使用方法

    Django ORM中原生JSONField的使用方法 带你尝鲜Django最新版重要更新JSONField的使用 Django最新版v3.1的主要更新之一便是完善了对JSON数据存储的支持,新增models.JSONField和forms.J...

  • 8
    • kevinmahoney.co.uk 3 years ago
    • Cache

    A Few Django ORM Mistakes

    21 January 2017 A Few Django ORM Mistakes See if you can figure out what's wrong with the code snippets below! Ask yourself what the problem is, what effect will it have, and how can you fix it? These ex...

  • 10

    Building RESTful APIs With Flask: An ORM With SQLAlchemy by Shalabh AggarwalOct 12, 2016(Updated Apr 11, 2022)

  • 8
    • limboy.me 3 years ago
    • Cache

    写了个基于SQLAlchemy的ORM

    看 Rails 时,觉得 Rails 的 ORM 用起来好方便,就想找找 python 有没有类似的,没发现太尽如人意的,就按照自己的意愿,基于 SQLAlchemy Core 重新写了个,取名为 Thing,项目主页: "https://github.com/limboy/thing":https://github.com/limboy/thing

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK