Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
Berkeley DB 介面
|
397
v2 中,這兩個範例應該匯入並使用模組
anydbm
而非套件
dbm
Berkeley DB 介面
v2 附有
bsddb
套件,它包裹了 Berkeley Database(也叫做 BSD DB)程式
庫,如果你的系統上有安裝那個程式庫而且你的 Python 安裝建置的時候有
設定支援它的話。然而,
bsddb
v2 中已被棄用,而在 v3 中則不存在,所
以我們無法推薦它。如果你確實需要對一個 BSD DB 封存檔(archive)的
介面,我們建議改用極佳的第三方套件 bsddb3
https://pypi.python.org/pypi/
bsddb3
)。
Python Database APIDBAPI2.0
如我們前面提過的,Python 標準程式庫並沒有內附 RDBMS 介面(除了涵
蓋於「SQLite」的
sqlite3
,它是功能豐富的實作,不只是一個介面)。有
許多第三方的模組都能讓你的 Python 存取特定的 DB。這種模組大多遵循
Python Database API 2.0 標準,也叫做 DBAPI,如 PEP 249
https://www.
python.org/dev/peps/pep-0249/
)中所規範的。
匯入 DBAPI 相容的模組之後,以 DB 特定的參數呼叫該模組的
connect
式。
connect
回傳
x
,它是
Connection
的一個實體,代表對 DB 的一個連
線。
x
支援
commit
rollback
方法來處理交易 ...
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.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819