Does SQLite have a machine portable file format that the C API can read/write?

北战南征 提交于 2019-12-06 07:58:33

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/2157330/does-sqlite-have-a-machine-portable-file-format-that-the-c-api-can-read-write

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!