4

I am looking for a database that can I run SQL statements on without having to have a database server installed. I.e. I need the ability to select/insert/update a database given only the database file and any external libraries.

Here is my situation:

  • I am using C++ to parse through a number of oddly-formatted binary files, and I would like to store them into some type of database to offer more convenient access to the data.
  • Once the files have been inserted into the database, I will use C# to write an interface/GUI by which a user can interact with the database.
  • I'm using C++ for the speed of reading the files and because I've already written that part.
  • I'm using C# because it is much easier to do GUI programming.

Here are my requirements:

  1. Database must provide a way to run commands in C++ using only external libraries (no installation)
  2. I should be able to move the database to any (similar [Windows]) computer and run my application

I believe this is possible with MS Access *.mdb files using ADO or JET or something like that, however, I would like to hear some alternatives. Please provide the database and the C++ engine/libraries in your answer.

My priorities are:

  1. "Lite"-ness
  2. Performance (speed of insert/select)
  3. Client code simplicity (i.e. how easy it is to set up)

Thank you all.

Chris Eberle
  • 47,994
  • 12
  • 82
  • 119
Eric
  • 2,098
  • 4
  • 30
  • 44
  • The first thing I thought of was MS Access. It's a very powerful tool. My main objection to it is that it is too powerful for some idiot "superusers". It's very easy to get unintended results, and very hard to trace through multiple layers of queries. But if you know what you're doing, well, why not? You can always migrate to something else later if you find you need more horsepower. – DOK Jun 04 '11 at 18:50
  • @DOK: Thanks. One advantage of Access is that Office is installed on many computers, which would be really convenient. Also, being consistent with Microsoft products is a plus, in my opinion. I also looked into SQL Server CE, but I wasn't satisfied with the C++ resources. I actually used Access for a C# project a while ago, and it worked for my purposes, but I found it somewhat lacking in features. – Eric Jun 04 '11 at 21:57

2 Answers2

6

You need to look into SQLite. It is perfect for this scenario and very easy to use. It is vastly popular (large community), compact, cross-platform, and simple to use.

There are SQLite implementations for other languages too. For instance, you can also access SQLite databases using C#. There is even a Linq-to-SQLite.

Jordan Parmer
  • 36,042
  • 30
  • 97
  • 119
  • 1
    +1, totally agree. However the OP should know that SQLite isn't so great on performance (it was a listed priority). – Chris Eberle Jun 04 '11 at 18:44
  • 3
    True. But performance can be vague to measure. It all depends on size of records, size of database, complexity of relationships, etc. I recommend trying it to see if it works with the data first. – Jordan Parmer Jun 04 '11 at 18:45
  • 1
    If he decides on SQLite, he'll need access from C#. A previous question covered that aspect: http://stackoverflow.com/questions/93654/is-there-a-net-c-wrapper-for-sqlite – Jerry Coffin Jun 04 '11 at 18:57
  • Thank you for the information. I LOVE Linq, so Linq-to-SQLite is great news. Unfortunately I can only select one answer, so Dirk gets the check mark because he posted first (by about 2 minutes) :) @Chris: I will keep your comment in mind. I'm going to give SQLite a shot and see if it works for me. Thanks! @Jerry: I kind of assumed there would be a decent C# wrapper for just about any database that might come up, but you've saved me a search. Thanks for the link! – Eric Jun 04 '11 at 21:51
5

You cannot go wrong with SQLite here.

It is small enough to be embedded in many apps (see e.g. here for a list of famous apps ranging from Photoshop to Apple Mail + Safari, Dropbox, Firefox, Chrome, Skype and more), yet complete enough to cover most SQL aspects you may need. Great support too, and wide coverage in terms of APIs and languages.

It can have issues with locks and multiple write accesses. But for a single client it should work perfectly fine.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Interesting link. I was not aware SQLite was so popular. Will definitely give this a shot. Thanks! – Eric Jun 04 '11 at 21:47