SQLite for C# – Part 1 – Am I allowed to use it?

I’ve been interested in databases for a long time, but to date they have always been the ‘big’ server class kind. Just recently I had the need to look for a lightweight in memory DB. Naturally I was thinking SQL CE (or as it appears to be now known as “SQL Server Compact 3.5“) for the job. A friend nudged me to look at SQLite (please note it only has one ‘L’ in its name and typing that and not SQLLite is killing me :-) )

Licensing

So before we go any further I’ll cover the licensing aspect of SQLite, as there is no sense reading up and getting excited about a product and then determining the licensing doesn’t work for you! Here I have GREAT news, it is the simplest of all licensing models – all code is in the Public domain . Read the exact SQLite license text information here, but frankly it cant get much simpler! For those not wanting to follow the links here are the Cliff notes:

“Anyone is free to copy, modify, publish, use, compile, sell, or distribute the original SQLite code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. “

No GPL ‘virus’ risk (please no flames but licensing has got very hot over the years and a fair number of companies get very touchy about what is going into their proprietary code base), no proprietary vendor lock in, no need to acknowledge the product or authors (although I certainly do recommend you do this out of professional courtesy!)

So everyone should be good on the licensing side of things! On to how do I get this DB into C# land! First thing you will probably notice is that the SQLite web site is not that user friendly to finding things, if you persist you will find that the information is normally in there – the trick is finding it! The primary audience for SQLite really appears to be targeted to C or C++ programmers, and most likely in an embedded solution, but keep reading! There are a number of projects that have wrapped the SQLite access layer for other languages (see SQLite wrappers), but again that page is not all that helpful to C# programmers. The best location for the C# codebase access can be found here http://sourceforge.net/projects/sqlite-dotnet – at time of writing the latest version is 1.0.61.0 (2009-04-28) – again this is licensed as Public Domain so we are all still good. The reassuring thing about sqlite-dotnet is that if you look at the version history this projects first release was Feb 21, 2005. That frankly is nice, reassuring & impressive! In addition they keep pretty up to date with the base product which is again nice.

So to recap at this point there are no licensing issues that may prevent you from using this, and while the official web site doesn’t help out the C# programmers there is a strong community over at http://sqlite.phxsoftware.com/ .

Installation

Out of the box we are going to keep it simple and just use the standard installer on the web site.  The slightly odd part to me about the installer is that is doesn’t explicitly have any licensing page – I understand why, but in today’s world it is a little unusual. Anyway below are some screen shots of the install to give everyone a warm fuzzy about the installation process:

Install Startup:

SQLite Installation - Welcome

Select the folder:

SQLite - Installation directory

Ready to install:

SQLite - Ready to Install

The actual installation:
SQLite Installing

Prompt to choose the VS add-in (if required)
SQLite Chose VS add-ins

Ta-Da – we are complete!
SQLLite Installation Complete

The next blog will be Part2, ok you have got me to install it – how do I use it!

Mono Footnote :-)

Finally what I didnt mention above is that SQLite and the C# drivers also work for Mono. So anyone looking to keep the flexibility to migrate their solution over to a Linux platform this technology choice doesnt prevent that in any way.

Related Links:

4 Responses to “SQLite for C# – Part 1 – Am I allowed to use it?”

  1. Ahmed says:

    Thank you for the great step-by-step lesson,carry on man

  2. [...] SQLite for C# – Part 1 – Am I allowed to use it? « C# Hacker – The Rambling Coder Using c #and SQLite. (tags: c# .net sqlite) [...]

  3. John says:

    Gareth, you’re a lifesaver. Thanks a billion! :D

  4. Santosh says:

    Many many thanks for this great article. This is the first article that helped me to write Hello World in SqlLite. Thanks a ton.

Leave a Reply