Skip to Content
Flask Web开发:基于Python的Web应用开发实战(第2版)
book

Flask Web开发:基于Python的Web应用开发实战(第2版)

by Miguel Grinberg
August 2018
Intermediate to advanced
230 pages
6h 42m
Chinese
O'Reilly Media, Inc. Beijing
Content preview from Flask Web开发:基于Python的Web应用开发实战(第2版)
46
5
5.3
 使用
SQL
还是
NoSQL
SQL
数据库擅于用高效且紧凑的形式存储结构化数据。这种数据库需要花费大量精力保证
数据的一致性,需要考虑停电或硬件失效。为了达到这种程度的可靠性,关系型数据库
采用一种称为
ACID
的范式,即
atomicity
(原子性)、
consistency
(一致性)、
isolation
(隔
离性)和
durability
(持续性)。
NoSQL
数据库放宽了对
ACID
的要求,从而获得性能上的
优势。
对不同类型数据库的全面分析和对比超出了本书范畴。对中小型应用来说,
SQL
NoSQL
数据库都是很好的选择,而且性能相当。
5.4
 
Python
数据库框架
大多数数据库引擎都有对应的
Python
包,包括开源包和商业包。
Flask
并不限制你使用
何种类型的数据库包,因此你可以根据自己的喜好选择使用
MySQL
Postgres
SQLite
Redis
MongoDB
CouchDB
DynamoDB
如果这些都无法满足需求,还有一些数据库抽象层代码包供选择,例如
SQLAlchemy
MongoEngine
。你可以使用这些抽象包直接处理高等级的
Python
对象,而不用处理如表、
文档或查询语言之类的数据库实体。
选择数据库框架时,要考虑很多因素。
易用性
如果直接比较数据库引擎和数据库抽象层,显然后者取胜。抽象层,也称为对象关系映
射器(
ORM
)或对象文档映射器(
ODM
),在用户不知不觉的情况下把高层的面向对
象操作转换成低层的数据库指令。
性能
ORM
ODM
把对象业务转换成数据库业务时会有一定的损耗。多数情况下 ...
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

Python机器学习基础教程

Python机器学习基础教程

Andreas C. Müller, Sarah Guido
Python编程入门与实战

Python编程入门与实战

Posts & Telecom Press, Fabrizio Romano
程序设计导论:Python语言实践

程序设计导论:Python语言实践

罗伯特 塞奇威克, 凯文 韦恩, 罗伯特 唐德罗

Publisher Resources

ISBN: 9787115489456