TDBF, your free, open source, Delphi database engine!
One of Delphi’s strengths has always been it’s support for databases. Even back in the day I remember C++ users looking over my shoulders at how easy it was for me to create a database application, while they themselves had to commit proverbial warfare on some bulky, esoteric API just to store lists. So when it comes to databases Delphi programmers have been spoiled rotten with an impressive menu of drivers and native engines.
But as always there is a catch, and that catch used to be that you had to ship the BDE with your applications (which at the time was “wow, that simple?” factor. The basic and C guys had it much worse) if you were going to work with Interbase, Paradox or DBase – which were the heroes back then.
Like many others I decided to skip the whole BDE and opt for a native, embedded database engine. Meaning a full database system written in Delphi itself as opposed to C/C++ (which really is the paradox here, since working with databases under C++ was a bit like shaving with a cheese grinder: slightly amusing but mostly painful). And I mean no disrespect to any Delphi database engine author, but DBISAM was king, only topped by ElevateDB which is it’s successor (and very much alive and kicking to this day). So if you want a solid database engine which is embedded (meaning: compiled into your program) ElevateDB is worth every penny.
At the end of the day, what Delphi had (and still has to some extent) to offer is:
- Pretty much the best support for popular databases out of the box (read: drivers)
- A wide variety of database engines written in Delphi
As you probably guess, none of these options are really free. And those that are free, like FireBird, requires a lot of reading or studying of code to get working. Now please don’t get me wrong, I really want to avoid any debate situation where some Firebird guy wants to protect his favorite database. The point is simply this: if you know absolutely nothing about Firebird or Interbase and you just want a quick “drop in” component which gives you database capabilities, then Firebird can be pretty daunting. It’s a serious piece of software engineering which means you should know what you are doing and have the time to learn exactly that.
Take myself as an example: I spent a whole day trying to connect to a FB database, only to discover way into the dark hours that there were in fact two different FB versions. Had this been explained in right at the start I could have spent my day making my actual database rather than googling for error codes and exception identifiers. Secondly, the Firebird team should ship a simple Delphi demo complete with the embedded version – ready to be used by anyone.
And last but not least, FireBird doesn’t always play nice with Interbase components – and getting everything to work out of the box (I ended up with Zeos component set) can’t really be compared to the smooth sailing that is ElevateDB or DBISAM. There you just install, drop the components on a form or datamodule — voila, that’s it.
Shooting sparrows with a canons
While all of this is well and good, with plenty of drivers and support for popular technology from mySQL to MSSQL to Firebird and whatnot, dont you find it to be overkill? I mean for small projects?
For instance, I was writing a simple movie collection program a few years back, which downloaded the movie cover online and figured out things like what year the movie was made etc. based on name and online sources. My database needs very humble to say the least, something between 5 to 100 megabytes maximum. My first “test” database did not take up more than 30 megabytes (using TClientDataset which bloats everything by storing data as variant no matter what).
So where is the alternative? Do I really need to fork out $300 for a native Delphi engine just to store between 5 and 100 megabytes of data in a sequential, indexed and searchable way? And if I go for the “free” alternatives, how many hours do I have to work just to get the database engine working in the first place? Having played around with mySQL embedded, SQL Server light and Firebird – sticking to Windows and using ElevateDB seemed like the best option.
But having seen what ships with Visual Studio, Mono C# and even Lazarus/FreePascal I felt outright annoyed that Embarcadero had absolutely no free, built-in (so to speak) alternative. The only possible alternative was TClientDataset, which is perfect in terms of functionality (you rarely need SQL when dealing with such a small amount of non-complex data) — but it’s not a disk based table and quickly eats up memory once you start stuffing blobs into it.
I wanted a small, compact and humble database solution that may not be the fastest gun in the west, but at least you could trust it to scale properly and be written in such a way that it’s portable.
TDBF to the rescue
For the past couple of years I have held an eye on the database segment of Delphi, hoping that someone out there had either written a native Delphi database engine which was free and open-source, or that someone had taken the time to compile SQLite to .lib files and turned it into a TDataset descendant. The closest thing I came to a good clean production of SQLite was from Synopse — but just when I thought I had finally found what I was looking for, they decided to include it in their mORMot framework — adding a lot of dependencies which I quite frankly did not want.
As my search continued, I finally stumbled across a project which fit my needs! It’s a very small piece of database kit called TDBF, written in Delphi and compiles straight into your exe file.
To quote the Sourceforge website:
TDBF is a freeware native data access component for Borland Delphi, C++Builder and Kylix, and for FreePascal. It allows you to create very compact database programs that don’t need any special installer programs. In fact the code to access your database is compiled in your project executable file.
It takes only a few kilobytes in your executable and doesn’t need any other external files to run.
That is spot on perfect for my needs, and I’m guessing others as well. Having a simple “drop in” database which can be used for anything, speed not withstanding, should be considered a primer for any native programming language. I sincerely hope that Embarcadero either pick up this open-source project as a low-end alternative to Interbase Embedded (or perhaps sqLite would be more suitable).
If you visit the website you will find that it has quite a few years of development behind it. Secondly, if you check the SVN you will see that it was updated in 2013 (last year) so you should probably check out the code via SVN, since the website havent been updated in 7 years. But that doesn’t necessarily mean anything bad, there are plenty of components which doesn’t need updates because they work just fine. But I know many people regard “recent updates” as a sign of quality, so I’ll just mention this — the website havent been updated, but the code has (!)
The author has done a great job in keeping it backwards compatible with earlier Delphi releases (all the way to Delphi 3), but personally my absolute lowest possible limit would be Delphi 7, which I consider “classic object pascal” but even that can be discussed right now since we just moved to XE6. Either way, I will probably do a little cleanup of the code to get rid of legacy support and assembler segments.
And that’s another positive point: it’s platform independent from the ground up, designed to compile under both Delphi and freepascal. That is very nice because I am moving more and more code to Linux these days, and having a small and compact database engine which is portable and free is most welcome!
So if you are looking for a simple, clean, functional and free database engine written in object pascal which you can use anywhere — then I sincerely urge you to download and give TDBF a try. I also hope someone out there takes the time to fork this project and keep it alive (I only have time for my own stuff right now) because it’s something the Delphi community needs!
Although it ships with some 15 units, the content of the units is surprisingly small – so you could easily pack it all into a single unit without turning it into a mess. I love it when cool technology fits nicely inside a single unit with no dependencies 🙂
Im actually hoping to port some of it to Smart Mobile Studio later !
- Ships with several localization units (French, English, German, Spanish, Italian and more)
- Compiles under Delphi and Freepascal
- Platform independent (Windows, Linux and Unix)
- No dependencies or external drivers, compiles into your program
- Very small footprint, only adds a few KB to your exe file
- Perfect for small projects and mobile applications
- Compatible with DBase
- Memo field support (dynamic size fields)
- Indexing supported, fast lookup and searching
- Derives from TDataset (standard Delphi database framework)
Click here to visit the website. See the “SF Project Page” link to view the sourceforge SVN repository
The vatican vault
- March 2017
- February 2017
- January 2017
- December 2016
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- May 2016
- April 2016
- March 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- August 2013
- July 2013
- June 2013
- May 2013
- February 2013
- August 2012
- June 2012
- May 2012
- April 2012