A simple in-RAM database system written in C++.
This library allows you to dynamically create tables, rows, cells, and variables during runtime.
It is header-only (with one .hpp file) and easy to integrate into any C++17+ project via simple namespace. No API, or side processes.
Clone the repository or copy the file kramdb.hpp into your project:
git clone https://github.com/krejciad/kramdb.gitThen include it in your source code:
#include "kramdb.hpp"Or, you can use Microsoft Visual Studio solution file as starting point.
kramdb.sln
kramdb.vcxprojNo external dependencies are required beyond the C++ standard library.
DB::NEW();Create a instance of table in vector as DB::TABLE[id], id starts on 0.
DB::TABLE[0].NEW();
DB::TABLE[0].ROW[0].NEW();Same system as with tables.
DB::TABLE[0].ROW[0].CELL[0].NEW(TYPE::Integer);
DB::TABLE[0].ROW[0].CELL[0].cellInteger[0] = 15;Current supported TYPEs are Integer, Float, Boolean and String.
std::cout << DB::PRINT(table); // compact one-line output
std::cout << DB::TREE(table); // pretty tree structureAnd, of course, you can print the variables directly:
std::cout << DB::TABLE[0].ROW[0].CELL[0].cellInteger;#include "kramdb.hpp"
#include <iostream>
int main() {
DB::NEW(); // create table
tableObj& t = DB::TABLE[0];
t.NEW(); // row 0
t.ROW[0].NEW(); // cell 0
// add data
t.ROW[0].CELL[0].NEW(TYPE::Integer);
t.ROW[0].CELL[0].cellInteger[0] = 100;
t.ROW[0].CELL[0].NEW(TYPE::String);
t.ROW[0].CELL[0].cellString[0] = "User";
// print results
std::cout << DB::PRINT(t);
std::cout << DB::TREE(t);
}// Remove row 0 from the table
DB::REMOVE(t.ROW, 0);
// Remove cell 0 from row 0
DB::REMOVE(t.ROW[0].CELL, 0);The library provides a quick way to generate a sample table for testing:
tableObj demo;
DB::createDemoTable(demo);
std::cout << DB::TREE(demo);std::cout << DB::easterEgg(1);DB::NEW()→ create a new table in memorytableObj.NEW()→ add a new row to a tabletableRowObj.NEW()→ add a new cell to a rowtableCellObj.NEW(TYPE type)→ add a variable (Boolean, Integer, String, Float) to a cellDB::REMOVE(container, index)→ remove element from a vector (table, row, or cell)DB::PRINT(table)→ return compact string of table contentsDB::TREE(table)→ return pretty-printed structure of tableDB::createDemoTable(table)→ generate a pre-filled test tableDB::easterEgg(n)→ print a fun easter egg
Licensed under Creative Commons CC-BY-4.0 ©2025.
See LICENCE.