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

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

目录
相关文章
|
2月前
|
API 数据库 C语言
【C/C++ 数据库 sqlite3】SQLite C语言API返回值深入解析
【C/C++ 数据库 sqlite3】SQLite C语言API返回值深入解析
171 0
|
4月前
|
存储 数据库连接 数据库
Android数据存储:解释SQLite数据库在Android中的使用。
Android数据存储:解释SQLite数据库在Android中的使用。
43 0
|
3月前
|
存储 监控 安全
内网屏幕监控软件的数据存储与管理:使用SQLite数据库保存监控记录和配置信息
在当今数字化时代,安全和监控在企业和组织中变得至关重要。内网屏幕监控软件作为一种关键工具,帮助组织监视员工的活动并确保信息安全。这种软件不仅需要高效地记录和管理监控数据,还需要能够方便地进行配置和调整。本文将讨论如何使用SQLite数据库来保存监控记录和配置信息,并介绍如何通过自动化机制将监控到的数据提交到指定网站。
184 2
|
7天前
|
SQL 存储 Ubuntu
在ubuntu中将dict.txt导入到数据库sqlite3
这样,你就成功将 `dict.txt` 中的数据导入到名为 `mydatabase.db` 的SQLite3数据库中的 `words` 表格中了。请根据实际情况调整表格结构和数据导入命令。
14 0
|
18天前
|
SQL 数据库 数据库管理
Python数据库操作(SQLAlchemy、SQLite等)面试题集
【4月更文挑战第15天】本文介绍了Python数据库操作的面试重点,涵盖SQLAlchemy ORM和SQLite。内容包括:1) 使用SQLAlchemy定义SQLite表的Python类及执行CRUD操作,强调ORM使用和会话管理;2) 查询优化与性能,涉及JOIN、分组、聚合查询,并提醒注意懒加载和索引创建;3) 异常处理和事务管理,展示如何捕获异常并进行事务控制。通过理解这些知识点并避免常见错误,可在面试中表现出色。
21 0
|
23天前
|
SQL 关系型数据库 数据库
Python中SQLite数据库操作详解:利用sqlite3模块
【4月更文挑战第13天】在Python编程中,SQLite数据库是一个轻量级的关系型数据库管理系统,它包含在一个单一的文件内,不需要一个单独的服务器进程或操作系统级别的配置。由于其简单易用和高效性,SQLite经常作为应用程序的本地数据库解决方案。Python的内置sqlite3模块提供了与SQLite数据库交互的接口,使得在Python中操作SQLite数据库变得非常容易。
|
28天前
|
关系型数据库 MySQL 数据库连接
Python+SQLite数据库实现服务端高并发写入
Python中使用SQLite内存模式实现高并发写入:创建内存数据库连接,建立表格,通过多线程并发写入数据。虽然能避免数据竞争,但由于SQLite内存模式采用锁机制,可能在高并发时引发性能瓶颈。若需更高性能,可选择MySQL或PostgreSQL。
33 0
|
2月前
|
数据库连接 API 数据库
SQLite3 数据库 C语言API 打开函数sqlite3_open 详解
SQLite3 数据库 C语言API 打开函数sqlite3_open 详解
52 0
|
2月前
|
关系型数据库 数据库 C++
嵌入式数据库sqlite3【基础篇】基本命令操作,小白一看就懂(C/C++)
嵌入式数据库sqlite3【基础篇】基本命令操作,小白一看就懂(C/C++)
|
2月前
|
存储 SQL 数据库
django如何连接sqlite数据库?
django如何连接sqlite数据库?
83 0