SQLite

来源:互联网 发布:c 串口接收数据 编辑:程序博客网 时间:2024/06/01 10:35

  When I first see the sqlite, I feel it's good . So I record something about it.

self-contained:

1.sqlite is largely self-contained.It requires very minimal support from external libraries or from operating system.This makes if well suit for use in embedded devices that lack the support infrastructure(基础设施) of a desktop computer.This also makes sqlite appropriate for use within applications that need to run without modification on a wide variety of computers of varying configurations.

 2.sqllite is written in ANSI-C and should be easily complied by any standard C compiler.It makes mininal use of the standard C library.The only required c library functions called are:

.memset()

.memcpy()

.memcmp()

.strcmp()

.malloc(),free(),and realloc()

 3.Communications between sqlite and the OS and disk are mediated through an interchangeable VFS layer.VFS modules for unix and windows are provide in the source  tree.It's a simple matter to devise an alternative VFS for embedded devices.

 4.The sqlite source code is available as an "amalgamation"(http://www.sqlite.org/amalgamation.html)- a single large c source code file.Projects that wanna include sqlite can do so simply by dropping this one source file(named "sqlit3.c") and its corresponding header("sqlite3.h")into their source tree and compiling it together with the rest of the code.Sqlite doesn't link against any external libraries(other than the C library,as described above) and does not require any special build support.


serveless:
 

1. Most sql database engines are implemented as a separate server process. Programs that want to access the database communicate with the servere using some kind of interprocess communication(tipicallly TCP/IP)to send requests to the server and to receive back the results.Sqlite does not work this way.With sqlite,the process that wants to access the database reads and writes directly from the database files on disk.There is no intermediary server process.

2.There are advantages and disadvantages to being serverless.The main advantage is that there is no separate server process to install,setup,configue,initialize,manage,and troubleshoot.This is one reason why sqlite is a "zero-configuration" database engine.Programs that use sqlite require no administratie support for setting up the database engine before they are run.Any program that is able to access the disk is able to use an sqlite database.On the other hand, a database engine that uses a server can provide better protection from bugs in the client application-stray pointers(流浪指针) in a client cannot corrupt memory on the server.And because a server is single persistent concurrency.

 3.Most sql database engines are client/server based.of those that are serverless,sqlite is the only one known to this author that allows multiple applications to access the same database at the same time.


 

  Sqlite is a compact library.With all features enabled ,the library size can be less than 350KB,depending on the target platform and compiler optimization settings.If optional features are omitted, the size fo the Sqlite library can be reduced below 300KB,SQlite can also be made to run in mininal stack space(4KB)and very little heap(100KB),making sqlite a popular database engine choice on memory constrained gadgets such as cellphones,PDAs,and MP3 players.There is a tradeoff between memory usage and speed. sqlite generally run faster the more memory you give it.Nevertheless, performance is usually quite good even in low-memory environment.