嵌入式系统上的 Sqlite

2022-01-25 00:00:00 database embedded sqlite

我有一个使用 Sqlite 在 PC 上生成的数据库文件.然后将该文件传输到没有操作系统的基于 ARM7 的嵌入式系统.嵌入式系统必须访问这个数据库,但不需要更新它.

I have a database file that is generated on a PC using Sqlite. This file is then transferred to an ARM7 based embedded system without an operating system. The embedded system must access this database, but does not need to update it.

我一直在尝试让 sqlite3 足够小以适应嵌入式系统,但到目前为止,我无法将应用程序大小设置为低于 256 KB(我的限制).

I have been trying to get sqlite3 small enough for the embedded system, but so far I cannot get the application size under 256 Kbytes (my limit).

有没有人能够将 sqlite3 缩小到这个大小?有没有其他软件可以用来读取这个数据库?

Has anyone been able to get sqlite3 down to this size? Is there other software that I can use to read this database?

我正在尝试使用 C 访问数据库.这将使用 sqlite3_exec() 函数完成.

I am trying to access the database using C. This would be done using the sqlite3_exec() function.

有两张桌子.一个表有 ID 和文本,第二个表有 ID,链接到第一个表的 ID、文本和状态值.唯一需要的访问权限是通过第一个表上的 ID 或部分文本,以及第二个表上的 ID.

There are two tables. One table has an ID and text, the second an ID, link to ID of first table, text, and status value. The only access required is by ID or partial text on the first table, and by ID on the second table.

也许有一些独立的代码可以用来访问数据库?

Perhaps there is some standalone code that can be used to access the database?

推荐答案

我想出的最小的 sqlite3 是 327 KBytes(对于 PowerPC),这对于系统来说已经足够了,所以我不再尝试让它更小.这是完整的 sqlite3 CLI 二进制文件,单独的 C API 会更小.

The smallest sqlite3 I came up with was 327 KBytes (for PowerPC), which was sufficient for the system so I stopped trying to make it smaller. This was the full sqlite3 CLI binary, the C APIs alone would have been somewhat smaller.

我设置了 SQLITE_OMIT_AUTHORIZATION、SQLITE_OMIT_EXPLAIN、SQLITE_OMIT_PROGRESS_CALLBACK 和 SQLITE_OMIT_TCL_VARIABLE 来调整二进制文件的大小,并使用 -Os 将其调整到那个大小.

I had set SQLITE_OMIT_AUTHORIZATION, SQLITE_OMIT_EXPLAIN, SQLITE_OMIT_PROGRESS_CALLBACK, and SQLITE_OMIT_TCL_VARIABLE to trim the size of the binary, and used -Os to get it to that size.

相关文章