Click here to Skip to main content
13,548,904 members
Click here to Skip to main content
Add your own
alternative version


56 bookmarked
Posted 30 Nov 2003
Licenced BSD

DarkSide SQL Mini Version 1, The embedded database

, 23 Mar 2006
Rate this:
Please Sign up or sign in to vote.
An embedded database library in C++.


Providing local data storage in an application is a real problem faced by many a C++ programmer. To avoid getting oneself confused with low-level file handling routines and chores like data indexing, most programmers tend to use commercial database systems even for minimum data handling purposes. If your application doesn't need the capabilities of a complete RDBMS server, then a small and efficient database library that plugs into your source code will seem an interesting solution. DarkSide SQL Mini is an effort to create such a library. You can take this as a beta release and I want developers to test this code and report bugs before the stable release. You may find even this beta release useful in many of your projects. The best thing about DarkSide SQL Mini is that, unlike other embedded database libraries, you don't have to learn a new set of APIs. It provides a subset of SQL that you can use to define schemas and manipulate data. All you have to learn to use are two classes (Database and ResultSet) and two member functions (execute() and executeQuery())!. Everything else is plain SQL.

Using the code

DarkSide SQL Mini is a source code library. Copy all CPP files in the \dsqlm_1\cpp folder to your projects working directory, add the \dsqlm_1\include directory to your include path, link your object code with dsqlm_1\libdb41s.lib and you are done. You have a nice database system embedded in your application. Now on to some SQL lessons...

First include dsqlm.h in your CPP file:

#include "dsqlm.h"
using namespace dsqlm;

Next create a database object:

Database db("zoo");

This will create the folder zoo, if it does not exist. To create a table, call the CREATE TABLE command.

db.execute("CREATE TABLE animals(name varchar(40) indexed,age int,dob date)");

Data is inserted using the INSERT command:

db.execute("INSERT INTO animals VALUES('Joe',2,'2001-2-20')");

SELECT command is used to search and retrieve data:

ResultSet rslt = db.executeQuery("SELECT * FROM animals WHERE age > 1");
while( {
  cout << rslt.getString(1) << rslt.getString(3) << endl;

The above code will print the name and date of birth of all animals whose age is above 1. In addition to these commands, DarkSide SQL Mini supports DELETE, DROP TABLE, DROP DATABASE and OPTIMIZE commands. The installation contains detailed documentation on the library.

In the demo code, you will find a complete working program that demonstrates the use of various DarkSide SQL commands. Follow the instructions in DarkSide SQL Mini Help files to compile this code.

If you need a complete RDBMS server, you can download DarkSide SQL server for free.


  • Created: Nov 23rd, 2003
  • Updated: Nov 27th, 2003: Fixed bug in logical expression parsing.


This article, along with any associated source code and files, is licensed under The BSD License


About the Author

No Biography provided

You may also be interested in...

Comments and Discussions

GeneralOne Kind Information Sir Pin
GovindanHari3-Apr-09 2:17
memberGovindanHari3-Apr-09 2:17 
QuestionAgain bugs sir.... Pin
GovindanHari3-Apr-09 2:09
memberGovindanHari3-Apr-09 2:09 
AnswerRe: Again bugs sir.... Pin
Vijay Mathew Pandyalakal3-Apr-09 2:24
memberVijay Mathew Pandyalakal3-Apr-09 2:24 
GeneralRe: Again bugs sir.... Pin
GovindanHari4-Apr-09 2:58
memberGovindanHari4-Apr-09 2:58 
GeneralRe: Again bugs sir.... Pin
GovindanHari4-Apr-09 3:47
memberGovindanHari4-Apr-09 3:47 
Generalerror LNK2005 Pin
GovindanHari2-Apr-09 21:37
memberGovindanHari2-Apr-09 21:37 
GeneralRe: error LNK2005 Pin
Vijay Mathew Pandyalakal2-Apr-09 21:56
memberVijay Mathew Pandyalakal2-Apr-09 21:56 
Questionerror C2059 Pin
GovindanHari2-Apr-09 6:14
memberGovindanHari2-Apr-09 6:14 
AnswerRe: error C2059 Pin
Vijay Mathew Pandyalakal2-Apr-09 19:27
memberVijay Mathew Pandyalakal2-Apr-09 19:27 
Questioncompile error Pin
GovindanHari2-Apr-09 4:58
memberGovindanHari2-Apr-09 4:58 
AnswerRe: compile error Pin
Vijay Mathew Pandyalakal2-Apr-09 19:23
memberVijay Mathew Pandyalakal2-Apr-09 19:23 
GeneralSqlite Pin
newmodel27-Mar-06 4:20
membernewmodel27-Mar-06 4:20 
GeneralRe: Sqlite [modified] Pin
Vijay Mathew Pandyalakal27-Mar-06 15:47
memberVijay Mathew Pandyalakal27-Mar-06 15:47 
GeneralRe: Sqlite Pin
newmodel27-Mar-06 21:36
membernewmodel27-Mar-06 21:36 
GeneralRe: Sqlite Pin
Vijay Mathew Pandyalakal28-Mar-06 15:25
memberVijay Mathew Pandyalakal28-Mar-06 15:25 
Generalsource code of the library: libdb41s.lib Pin
ozmanothman9-Nov-04 16:04
memberozmanothman9-Nov-04 16:04 
GeneralRe: source code of the library: libdb41s.lib Pin
Vijay Mathew Pandyalakal9-Nov-04 16:35
memberVijay Mathew Pandyalakal9-Nov-04 16:35 
GeneralRe: source code of the library: libdb41s.lib Pin
ozmanothman10-Nov-04 3:50
memberozmanothman10-Nov-04 3:50 
Generalwarning massage Pin
ozmanothman6-Nov-04 9:37
memberozmanothman6-Nov-04 9:37 
GeneralRe: warning massage Pin
Vijay Mathew Pandyalakal7-Nov-04 16:49
memberVijay Mathew Pandyalakal7-Nov-04 16:49 assembly? Pin
arachno5-Nov-04 7:39
memberarachno5-Nov-04 7:39 
AnswerRe: .net assembly? Pin
Vijay Mathew Pandyalakal5-Nov-04 16:36
memberVijay Mathew Pandyalakal5-Nov-04 16:36 
GeneralCompile error Pin
Chong Ching Yu6-Jan-04 20:16
memberChong Ching Yu6-Jan-04 20:16 
GeneralRe: Compile error Pin
Vijay Mathew Pandyalakal8-Jan-04 0:42
memberVijay Mathew Pandyalakal8-Jan-04 0:42 
GeneralRe: Compile error Pin
Chong Ching Yu8-Jan-04 16:31
memberChong Ching Yu8-Jan-04 16:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180515.1 | Last Updated 23 Mar 2006
Article Copyright 2003 by AnOldGreenHorn
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid