SQLite 是否有 C API 可以读/写的机器可移植文件格式?

发布于 2024-08-19 16:22:08 字数 204 浏览 9 评论 0原文

我尝试过通过网络在不同操作系统和体系结构之间传递二进制 SQLite DB - 但没有成功。

大家都用什么格式?我尝试过复制 SQLite 的 shell.c 并使用修改后的 argc、argv、stdin 调用 shell_main() 的方法,在 Mac 上取得了成功。遗憾的是我正在为 iPhone 开发,但只在那里失败了。

每个人都会做这么可怕的事情吗?

I've tried passing binary SQLite DBs over the network between different OSes and architectures - it didn't work.

What format are you all using? I've tried an unholy hack of copying SQLite's shell.c and calling shell_main() with a hacked up argc, argv, stdin with success on Mac. Pity I'm developing for the iPhone and it fails only there.

Does everyone do such awful things?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

腻橙味 2024-08-26 16:22:08

这是 SQLite 的核心功能之一。

稳定的跨平台数据库文件

SQLite 文件格式是跨平台的。在一台机器上编写的数据库文件可以复制到具有不同体系结构的另一台机器上并使用。大端或小端、32 位或 64 位并不重要。所有机器都使用相同的文件格式。此外,开发人员承诺保持文件格式稳定并向后兼容,以便较新版本的 SQLite 可以读取和写入较旧的数据库文件。

大多数其他 SQL 数据库引擎要求您在从一个平台迁移到另一个平台时以及升级到较新版本的软件时转储和恢复数据库。

http://sqlite.org/ Different.html

检查传递数据库的代码。进行逐字节比较以确保传输后它们相等。这绝对应该有效。

Beyond Compare 具有良好的二进制文件比较支持。

This is one of the core features of SQLite.

Stable Cross-Platform Database File

The SQLite file format is cross-platform. A database file written on one machine can be copied to and used on a different machine with a different architecture. Big-endian or little-endian, 32-bit or 64-bit does not matter. All machines use the same file format. Furthermore, the developers have pledged to keep the file format stable and backwards compatible, so newer versions of SQLite can read and write older database files.

Most other SQL database engines require you to dump and restore the database when moving from one platform to another and often when upgrading to a newer version of the software.

http://sqlite.org/different.html

Check the code that's passing the databases. Do a byte-by-byte comparison to make sure they're equal after transfer. This definitely should be working.

Beyond Compare has good binary file comparison support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文