【原创】如何在 libgda 和 SQLite 之间作出选择

【原创】如何在 libgda 和 SQLite 之间作出选择,第1张

概述How to choose between Libgda and SQLite 如何在 libgda 和 SQLite 之间作出选择 (本文为 官方文档 翻译,以中英对照形式呈现) Libgda has been added as a new external dependency for GNOME 2.26, with now two database libraries: Libgda an How to choose between libgda and sqlite
如何在 libgda 和 sqlite 之间作出选择

(本文为 官方文档 翻译,以中英对照形式呈现)

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. 如果你打算在现在就能够访问多种数据库类型,或者你认为在将来需要这么做,libgda 是你的不二之选,因为 sqlite 只提供了对 sqlite 文件的访问。上述的比较是基于这样一个前提:你打算创建一个 sqlite 数据库,并且在 libgda 和 sqlite 之间做出选择。值得注意的是,libgda 在自身内部使用了 sqlite (并非重新实现,而是使用)来访问 sqlite 文件。
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. 从依赖性的角度:如果你期望软件包的安装依赖少,那么 sqlite 是更好的选择,因为它没有任何其他依赖,而 libgda 依赖于 Glib 和 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. 从数据访问的角度:sqlite 仅支持通过前向移动指针来进行数据读取,而 libgda 允许你在前向模式和随机访问模式(通过一些缓存策略实现)之间进行选择。当你需要运行一次 SELECT 语句后多次使用其返回结果时,后者的功能是重要的。
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). 从数据类型的角度:libgda (像大多数数据库引擎一样)强制要求在表中每一列的数据必须具有相同的类型。sqlite 并没有此限制(意味着,对于每一行而言,存在于某列中的数据可能具有不同的类型,取决于程序员如何处理)。

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,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 访问数据的 UI 接口:尽管这个尚不属于 libgda 的一部分,libgnomedb 已实现了一些与数据绑定有关的小程序。 总结

以上是内存溢出为你收集整理的【原创】如何在 libgda 和 SQLite 之间作出选择全部内容,希望文章能够帮你解决【原创】如何在 libgda 和 SQLite 之间作出选择所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1174451.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存