Irmante Astalavista

Simsalabim!!!
Blog ini bercerita tentang dunia IT, ilmu kebumian, dan lain-lain.

Wednesday, March 28, 2007

Basisdata portable SQLite

Gara-gara ada yang minta buat aplikasi pada flashdisk, Saya terpaksa mengobok-obok aplikasi flashdisk yang udah ada. Critanya reverse engine gitu. Aplikasi itu sebelumnya dibangun menggunakan engine Visual C++ .NET dan basisdata yang baru saya denger, namanya SQLite. Terraininformatica menguji kecepatan query basisdata ini dan ternyata paling cepat.

Todd Tanner menggambarkan basisdata ini begini:
SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine. Features include:

* Transactions are atomic, consistent, isolated, and durable (ACID) even after system crashes and power failures.
* Zero-configuration - no setup or administration needed.
* Implements most of SQL92. (Features not supported)
* A complete database is stored in a single disk file.
* Database files can be freely shared between machines with different byte orders.
* Supports databases up to 2 terabytes (241 bytes) in size.
* Sizes of strings and BLOBs limited only by available memory.
* Small code footprint: less than 250KiB fully configured or less than 150KiB with optional features omitted.
* Faster than popular client/server database engines for most common operations.
* Simple, easy to use API.
* TCL bindings included. Bindings for many other languages available separately.
* Well-commented source code with over 95% test coverage.
* Self-contained: no external dependencies.
* Sources are in the public domain. Use for any purpose.

Yang membedakan dengan basisdata openSource lainnya yaitu gak ada instalasi, gak ada konfigurasi macem-macem, dan tanpa interface! Jadi kembali seperti jamannya dbf dulu tapi dengan fitur yang jauh lebih mumpuni. Tinggal buat tabel, kolom, dan isinya pake perintah SQL... menggunakan command line di DOS :D. Bener-bener portabel kan...

Sebenernya situs unduh resminya hanya menyediakan:
- SQLite command line
- SQLite Analyzer command line
- SQLite DLL engine
- dan sourcecodenya

Tapi kalo dari kontributor SQLite, banyak memberikan fasilitas lain yang bisa cek di bagian Wiki-nya. Antara lain terdiri atas:

ManagementTools: Programs to manage and query SQLite databases.
ConverterTools: Programs to convert SQLite databases from/to other database formats and DBMSes.
SqliteWrappers: Code to use SQLite in various programming languages.
SqliteOdbc: Driver to access SQLite through ODBC
SqliteNetwork: Code to use SQLite over Networks.
SqliteReporting: Tools for producing reports from SQLite databases.
SqlitePorts: Ports to other operating systems/environments, not officially supported.
SqliteCompetitors: Comparisons between SQLite and other database engines
SqliteUsers: A list of projects and programs that use SQLite.

Yang dibutuhkan programmer sesungguhnya hanya warper SQLite (paket konektor penghubung antara SQLite database engine dengan bahasa program tertentu dalam satu kemasan). Contohnya untuk warper SQLite ADO.NET 2.0 Data provider ada di PHXSoftware dan untuk yang Visual Basic 6 ada websitenya pak Tanner.

So, programmer hanya perlu meletakkan warper SQLite (*.dll) itu pada satu direktori project, dan menambahkan command DLL pada kodingnya. Sebagai contoh pada Visual Basic 6 adalah sebagai berikut:

'// SQL Lite dll declarations:
Private Declare Sub sqlite3_open Lib "SQLite3VB.dll" (ByVal FileName As String, ByRef handle As Long)
Private Declare Sub sqlite3_close Lib "SQLite3VB.dll" (ByVal DB_Handle As Long)
Private Declare Function sqlite3_last_insert_rowid Lib "SQLite3VB.dll" (ByVal DB_Handle As Long) As Long
Private Declare Function sqlite3_changes Lib "SQLite3VB.dll" (ByVal DB_Handle As Long) As Long
Private Declare Function sqlite_get_table Lib "SQLite3VB.dll" (ByVal DB_Handle As Long, ByVal SQLString As String, ByRef ErrStr As String) As Variant()
Private Declare Function sqlite_libversion Lib "SQLite3VB.dll" () As String ' Now returns a BSTR
'// This function returns the number of rows from the last sql statement. Use this to ensure you have a valid array
Private Declare Function number_of_rows_from_last_call Lib "SQLite3VB.dll" () As Long

Contoh program VB6-nya ada di situsnya Pak Tanner juga. Tentunya Anda harus meletakkan SQLite3VB.dll pada direktori ekstrak.

OK Gitu dulu deh...

[irmant]

Labels:


1 Comments:

Blogger muhammad said...

..hmmm..

thx yah ;)

2:21 PM  

Post a Comment

Links to this post:

Create a Link

<< Home