3

觉得 django ORM 和 sqlalchemy 都不太好用

 2 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 感觉没啥区别,

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK