Introduction
Tntdb is database abstraction layer for C++.
The goals are:
- easy and safe to use
- automatic resource management
- database independent
- thin layer for best performance
- no SQL-abstraction
- use modern C++ with exceptions and STL
- support for multithreaded applications
A example, which lists the the content of a table:
#include <iostream>
#include <tntdb/connect.h>
#include <tntdb/statement.h>
#include <tntdb/row.h>
int main(int argc, char* argv[])
{
try
{
"select FIRST_NAME, LAST_NAME"
" from ADDRESS");
cur != stmt.
end(); ++cur)
{
}
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
}
Example: modify data:
#include <iostream>
#include <tntdb/connect.h>
#include <tntdb/statement.h>
#include <tntdb/row.h>
int main(int argc, char* argv[])
{
try
{
"insert into ADDRESS (ID, FIRST_NAME, LAST_NAME)"
" values (:id, :firstName, :lastName)");
.
set(
"firstName",
"Tommi")
.
set(
"lastName",
"Makitalo")
.
set(
"firstName",
"Linus")
.
set(
"lastName",
"Torvalds")
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
}