Libgda has been added as a new external dependency for GNOME 2.26, with now two database libraries: Libgda and SQLite. libgda 已做爲一個新外部依賴項被添加到 GNOME 2.26 中了,如此就出現了 libgda 和 SQLite 並存的局面。
This page offers some hints about how to make the choice between the two when writing an application which needs to store/access some data in a database. 本篇文章針對編寫須要進行存儲/訪問數據庫的應用程序時,如何在上述二者之間做出選擇給出了一些建議。
Comparison hints 差別方面
Of course if you want to either be able to access different databases types or you think you may need to in the future, Libgda is a better choice because with SQLite you can only access SQLite files. The comparison makes sense only if you want to create an SQLite database and have to decide between Libgda and SQLite to do it. Note that Libgda uses SQLite internally anyway (it's not a reimplementation) to access SQLite files.
Dependencies point of view: if you want very few dependencies, SQLite is a better choice as it has no dependency whereas Libgda depends on GLib and LibXML2.
Data access point of view: SQLite only allows reading data using a forward moving cursor, and Libgda allows you to choose between that mode and a random access data access mode (some caching is done). This point is important if you need to run a SELECT statement once and use the results several times.
Low level control point of view: if you need some very specific SQLite features, then it's better to use SQLite as Libgda does not allow you to access SQLite's API direclty.
從控制級別的角度:若是你須要使用某些特殊的 SQLite 特性,那麼你最好仍是直接使用 SQLite ,由於 libgda 不容許你直接對 SQLite API 進行訪問。
Additionnal features point of view: Libgda offers much more than just a wrapper around SQLite (or other database's APIs), if you need them, it's better to use Libgda than to reimplement them yourself.
從附加特性的角度:libgda 所提供的功能遠遠不止對 SQLite API 的封裝(或者其餘數據庫 API),若是你須要這些附加功能,使用 libgda 絕對是你的首選,由於你不須要本身從新造輪子了。
Raw performances point of view: by design SQLite is better (but not by much).
從性能表現的角度:在某些方面 SQLite 可能會更好(但也沒好那麼多)。
Data types point of view: Libgda (as most if not all databases engines) impose that for each column in each table the data be of the same type. SQLite does not impose this restriction (this means that for each row, the data in a column can be of a different type and it's up to the programmer to handle that).
One important thing to keep in mind is that changing from using SQLite to using Libgda (or the other way around) can be a long an painfull experience, so you need to make sure you choose the right one right from the beginning. 須要銘記於心的一件事:將使用 SQLite 的代碼轉變爲使用 libgda (或者相反),將是一個漫長而痛苦的過程。因此你最好從一開始就確保你的選擇是明智的。
Common points 共性方面
Here are some (more or less) common points between Libgda and SQLite: 下面是 libgda 和 SQLite 之間的一些共性方面:
both work on all major OSes (Linux/Unix, Windows, MacOS)
二者都可在大多數操做系統上工做(Linux/Unix, Windows, MacOS)
both are easy to use in the compilation process thanks to pkg-config
二者從編譯的角度來說都算易於使用(基於pkg-config)
both are well maintained
二者都獲得了很好的開發維護
Libgda's features SQLite does not have SQLite 所不具備的 libgda 的特性
SQLite is a database engine implementation, and as such it's not meant to compete feature for feature with database abstraction libraries like Libgda, ODBC or JDBC. However it's important to know what features are implemented in Libgda which you may need to implement yourself in your application if you use SQLite directly. SQLite 是一個數據庫引擎實現,正由於如此,其並不打算與 Libgda、ODBC 或 JDBC 一類的數據庫抽象庫進行各類特性比較。然而,你須要明確知道的是哪些特性在 libgda 中被實現了,而當你直接使用 SQLite 的時候卻須要你本身在程序中實現。
Those features are: 這些特性包括:
meta data retreival: obtaining information about database objects such as the tables and their columns, the triggers,...
元數據獲取:獲取數據庫對象的信息,如表信息,表中的列信息,觸發器信息,等等
multi-threaded access to connections
多線程同時對 connection 進行訪問
SQL parser
SQL 解析器
loading and saving XML or CSV files
加載和保存 XML 或者 CSV 文件
UI interface to the data: even though it's not (yet) part of Libgda, Libgnomedb implements some data bound widgets