Skip to Content
Python语言及其应用(第2版)
book

Python语言及其应用(第2版)

by Bill Lubanovic
March 2022
Intermediate to advanced
522 pages
13h 52m
Chinese
Posts & Telecom Press
Content preview from Python语言及其应用(第2版)
280
16
SQLAlchemy
表达式语言
SQLAlchemy ORM
使用
ORM
避免
SQL
的复杂性,似乎是一个自然而然的选择。你该这么做吗?有人认
为应该避免使用
ORM
,但也有人觉得这种批评过头了
。不管谁对谁错,
ORM
都是一种
抽象概念,而所有的抽象概念都是有漏洞的,在某些时候会出问题。当
ORM
不能满足你
的需求时,必须弄清楚其工作原理以及如何在
SQL
中修复
。可以借用如下这则网络迷因
Internet meme
3
有些人在碰到问题时会想:“我知道我得使用
ORM
”那么,他们现在有两个问
题了。
ORM
用于简单应用或是能将数据直接映射到数据库表的应用
。如果应用足够简单,你
也许可以考虑使用直截了当的
SQL
SQL
表达式语言。
16.5.7
其他数据库访问包
如果你在寻找能处理多个数据库的
Python
工具,希望功能比
db-api
多,但又不要像
SQLAlchemy
那么繁杂,以下两个包值得考虑。
dataset
宣称其目标是“懒人的数据库”。它在
SQLAlchemy
的基础上提供了可用于
SQL
JSON
CSV
存储的简单
ORM
records
宣称其目标是“凡人的
SQL
”。它只提供了
SQL
查询,在内部使用
SQLAlchemy
处理
SQL
方言问题
、连接池以及其他细节。
records
集成了
tablib
(参见
16.3.7
节),允
许你将数据导出为
CSV
JSON
和其他格式。
16.6 NoSQL
数据存储
关系数据库是矩形的,但是数据的形式各异,如果不做大量的努力和调整,可能很难适
应。这是一个方钉 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

可编程网络自动化

可编程网络自动化

Jason Edelman, Scott S. Lowe, Matt Oswalt
Python实用技能学习指南

Python实用技能学习指南

Posts & Telecom Press, Robert Smallshire, Austin Bingham
量子计算机编程:从入门到实践

量子计算机编程:从入门到实践

Eric R. Johnston, Nicholas Harrigan, Mercedes Gimeno-Segovia
Python编程入门与实战

Python编程入门与实战

Posts & Telecom Press, Fabrizio Romano

Publisher Resources

ISBN: 9787115586223