SQLObject 1.1.0 發佈,SQLObject 是一個流行的Python 資料庫物件映射框架,映射的規則就是表->類、欄位->屬性。
過提供用於運算元據庫表的類和物件,物件關係映射工具有助於提高生產率。 Python 最好的物件關係映射工具是 SQLObject —— 一個開放源碼專案,它幾乎完成程式設計資料庫所需的所有操作。 本文介紹 SQLObject 及其功能。 閱讀本文後,您將能夠不編寫任何 SQL 代碼而連接 Python 與資料庫。
當面向物件程式設計範例滿足大多數資料庫的關係範例時,通常會看到物件關係映射。 物件關係映射是這兩個世界的橋樑。 它允許您定義與資料庫表對應的類。 然後您可以使用這些類及其實例上的方法來與資料庫交互,而不用編寫 SQL。 使用物件關係映射並不意味著不需要知道HTTP://www.aliyun.com/zixun/aggregation/22.html">關係資料庫如何工作,而是不必要編寫 SQL,從而避免程式設計錯誤。
您可以找到一打以上的操作 SQL 資料庫的開放源碼 Python 包,這還沒包括用於連接 Python 與特定資料庫的特殊用途模組。 SQLObject 是其中最好的模組。 它是簡單易用的完全物件關係映射包。 SQLObject 幾乎可以完成程式設計資料庫所需的所有操作。
SQLObject 1.1版本資訊:
Features & Interface
SelectResults (returned from .select()) is allowed in IN(column, list). A different workaround is used in SQLiteConnection to prevent PySQLite from converting strings to unicode - in the case of a registered text conversion function PySQLite silently converts empty strings to Nones; now SQLObject uses text_factory instead and properly returns empty strings. It is now possible to declare one encoding for all UnicodeCol's per table (as sqlmeta.dbEncoding) or per connection (as co nnection.dbEncoding). Default (if dbEncoding is found neither in column nor in table nor in connection) is 'utf-8'.
Source code and internals
Decorators @classmethod and @staticmethod are used everywhere. All 'mydict.has_key(name)' checks were replaced with 'name in mydict'.
安裝說明:
You can install the latest release with:
easy_install -U SQLObject
You can install the latest version of SQLObject with:
easy_install SQLObject==dev
You can install the latest bug fixing branch with:
easy_install SQLObject==bugfix
If you want to require a specific revision (because, for instance, you need a bugfix that hasn't appeared in a release), y ou can put this in your setuptools using setup.py file:
setup(... install_requires=["SQLObject==bugfix,>=0.7.1dev-r1485"],)