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