SQLite for Delphi

Linas Naginionis
soundvibe
Published in
2 min readSep 27, 2011

With Delphi now being cross platform (Delphi XE2) the need to have a local database is probably higher as never before. SQLite greatly fits into this role — it is free, open source, cross platform, fast, powerful, etc… Probably it’s the best embedded database You can get. Personally, it is my favorite database. I’m using it also in “Sound Vibe” player. I hoped that the new Delphi XE2 will support it natively. Well, I guess it was too optimistic…
One day just browsing through the web I found Tim Anderson’s SQLite wrapper. I decided to have a look into it. And I basically liked what I saw. It was very simple, easy to understand. But it lacked some features I was hoping for. So I decided to extend it in my way…

Here it goes

Main features of my implementation:

  • Supports multiple platforms. Can be used in FireMonkey, console or VCL applications (by using VCL you can target only Windows platform). Use the power of SQLite in cross platform appplications. Note that in OSX you don’t even need to deploy libsqlite3.dylib, it is already included in the OS (you have to deploy sqlite3.dll with your application in Windows). Not tested in iOS , if somebody can test it, please give me a word.
  • Simple to use prepared statements
  • Can fetch data into your own data structure
  • Unicode enabled
  • Unit tested
  • Ability to add user functions to SQLite. You can register your custom functions (even aggregate ones) and use them in your SQL statements.
  • TDataset descendant (TSQLiteDataset) for using it in DB aware VCL projects.
  • Database encryption support (for encryption to work you must use different sqlite3 library file because default one does not support it. You can get it from here or here )
  • Database authorization support.
  • Supports Delphi 2009-XE2

You can get the source in the Google code through the svn. There are some demos and wiki pages which can help you to start with it. I am planning to add more work to this wrapper later. Feel free to check it out and comment on it.

--

--