Looking for a lightweight database

Cogman

Lifer
Sep 19, 2000
10,278
126
106
Hey all, I want to do a personal project (meal planner) and was looking for a good lightweight opensource database to use. it isn't going to be an extremely large database, just something to store several recipes, ingredients, and expiration dates.

Mostly this is just a "for fun" type project, thought it would be helpful in giving me a little training in working with databases.
 

Cogman

Lifer
Sep 19, 2000
10,278
126
106
How about Berkeley DB? It looks like it is fairly lightweight and doesn't require me to setup username and passwords.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
You can always use SQLite. It has API's for pretty much every language out there
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
sqlite is great and there is a great firefox extension that lets you manage it. It is self contained (no server requried, just a file) so it is great for small apps.
 

Cogman

Lifer
Sep 19, 2000
10,278
126
106
Ok, i've been trying to give SQLite a whirl but to no avail. perhaps you guys could give me a hand.

Here is the problem, I want to get the thing to create the database if it doesn't exist and create a new table if it doesn't exist. Right now, I can create the database file (which is empty) but when I execute the command to create a new table I get a segment fault. I wonder if it is because there is no callback function (even though the documentation says there doesn't need to be one).

Any suggestions?

The code

#include <sqlite3.h>
#include <iostream>

using namespace std;

bool createDataBase(sqlite3* db)
{
int rc = 0;
rc = sqlite3_open_v2("food.db", &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
if (rc)
{
cout << "Could not open database: " << sqlite3_errmsg(db) << endl;
sqlite3_close(db);
return false;
}
return true;
}

void createTable(sqlite3* db)
{
int rc;
char* errmsg = NULL;

cout << "Executing command...\n";

rc = sqlite3_exec(db,
"CREATE TABLE IF NOT EXISTS ingredients(name TEXT, amount INT, expires TEXT);",
NULL, NULL, &errmsg);

cout << "Checking for errors..\n";
if (rc != SQLITE_OK)
cout << "SQL Error: " << *errmsg << endl;
sqlite3_free(errmsg);
}

int main()
{
sqlite3* db;
if(createDataBase(db))
{
cout << "Created Database...\n";
createTable(db);
cout << "Created Table\n";
}
sqlite3_close(db);
return 0;
}
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
If you're working in java then HSQLDb is the way to go. It's completely in memory and can be started and setup with 5 lines of code.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |