Fork me on GitHub


StactiveRecord is a C++ library designed to make simple database use as simple as possible (in a static language). It was inspired by Ruby on Rail’s Active Record, however, no similar look, feel, or performance is guaranteed. It uses an Object-relational mapping pattern to represent records as objects. It also provides persistent object relationships (one to many, many to many, one to one).

Quick Example For Those In A Rush

See the simple example description page for a detailed description of this example.

#include <stactive_record.h>
#include <iostream>
using namespace stactiverecord;
using namespace std;

// Initialize the DB connection
Sar_Dbi * Sar_Dbi::dbi = Sar_Dbi::makeStorage("sqlite://:memory:");

class Person : public Record<Person> {
  Person() : Record<Person>() {};
  Person(int id) : Record<Person>(id) {};
  void sayhi() { cout << "Hello\n"; };
SAR_SET_CLASSNAME(Person, "Person");

int main() {
  Person bob;
  bob.set("fullname", "Robert Somethingorother");
  bob.set("age", 50);;

  ObjGroup<Person> people = Person::find(Q("age", between(40, 100)) && Q("fullname", startswith("Robert")));
  SarVector<string> fullnames = people.get_property<string>("fullname");
  cout << "Name is: " << fullnames[0] << "\n";
  delete Sar_Dbi::dbi; // only cleanup necessary
  return 0;



One or more of the following databases and their dev components:

Get The Source

Releases can be found on the releases page. You can also download the current development code using git:

git clone git://

Note that if you download a development release you will need current versions of the autotools installed, and you must run ./ first before following these instructions.


Enter the StactiveRecord directory and type:


You can use the following to see additional configuration options:

./configure --help


su root
make install