120 likes | 254 Views
Standalone Databases. In the name of Allah. Iman M.Gowhari imanmgowhari@fastmail.fm. Introduction Mylittlebase SQLite Other Solutions. Introduction. Embedded database. The size of the database. The database performance. No end-user configuration required. Mylittlebase.
E N D
Standalone Databases In the name of Allah Iman M.Gowhari imanmgowhari@fastmail.fm
Introduction • Mylittlebase • SQLite • Other Solutions
Introduction • Embedded database. • The size of the database. • The database performance. • No end-user configuration required.
Mylittlebase • It is a little database component. • Function-call API for data access and management. • No need to link to any external server, DLLs. • Delphi / C++ / PHP http://www.mylittlebase.org
Mylittlebase #include <stdio.h>;#include "mlb2.h";int main() { TMlb2* mlb; mlb = mlb->Create(); printf("%d\n", mlb->GetVersionNumber()); mlb->Destroy();}
Mylittlebase • Initialization: Create, Destroy, Init, … • Fields: AddField, SetFieldType, SetFieldName, … • Rows: AddRow, GetCurrentRow, … • Navigation: GoFirst, GoNext, SeekData, … • Data management: GetData, SetData, … • File management: SaveToFile, LoadFromFile, … • Utils: MakeDistinct, SortByData, …
Mylittlebase #include <stdio.h> #include "mlb2.h" void main() { TMlb2* mlb; mlb = mlb->Create(); mlb->LoadFromFile("data.csv"); mlb->GoFirst(); mlb->BeginSeek(MLB_FORWARD); while(mlb->SeekData("city", "LIKE", "Lond*")) { // insert here your action } mlb->EndSeek(); mlb->Destroy(); }
SQLite • It is a C library that implements an embeddable SQL database engine. • Implements most of SQL92. • Very simple C/C++ interface requires the use of only three functions and one opaque structure. • Two times faster than PostgreSQL and MySQL for many common operations. http://www.sqlite.org
SQLite int main() { sqlite *db; char *zErrMsg=0; int rc; db=sqlite_open("test.db", 0, &zErrMsg); if( db==0 ) { printf("Can't open database: %s\n", zErrMsg); return 1; } rc=sqlite_exec(db, "select * from tbl1", callback, 0, &zErrMsg); if( rc!=SQLITE_OK ){ printf("SQL error: %s\n", zErrMsg); } sqlite_close(db); return 0; }
SQLite static int callback(void *NotUsed, int argc, char **argv, char **azColName){ int i; for(i=0; i<argc; i++) { printf("%s=%s\t", azColName[i], argv[i] ? argv[i] : "NULL"); } printf("\n"); return 0; }
SQLite • Accessing Data Without Using A Callback Function. • SQLite is typeless. • Python, Ruby, Perl, PHP, …
Other Solutions • Berkeley DB(http://www.sleepycat.com) • Ebase(http://ebase.sourceforge.net) • Gadfly(http://gadfly.sourceforge.net)