Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » General » Downloads
Add your own
alternative version

DarkSide SQL Mini Version 1, The embedded database

, 23 Mar 2006 BSD
An embedded database library in C++.
#include <iostream>
using namespace std;

#include "dsqlm.h"
using namespace dsqlm;

int main() {
  try {
    Database db("weather");	

	// create a table to store temperatures at different times of a day
	db.execute("create table temperatures(id autoid,rec_date date indexed,"
		"rec_time time,temp float)");
	char sql[101];
	float temp;
	while(true) {
		cout << "Enter temperature (0 to exit): ";
		cin >> temp;
		if(temp == 0) break;

			"insert into temperatures values(0,'sysdate','systime',%.2f)",
		// find out todays average temperature
		ResultSet rslt = db.executeQuery("select temp,rec_time from temperatures where rec_date = 'sysdate'");		
		float tot = 0;
		int count = 0;
		cout << endl;
		while( {
			cout << "Temp: "<<rslt.getString(1)<<"Recorded at: "
			tot += rslt.getFloat(1);
		cout << "Today's average temperature: " << (tot/count) << endl;
   }catch(DsqlMException ex) { 
     cout << ex.getMessage(); 
   return 1;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


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


About the Author

No Biography provided

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