1
0
mirror of https://git.ireas.org/sqlitepp/ synced 2024-10-06 06:52:52 +00:00
C++ binding for the SQLite library https://code.ireas.org/sqlitepp/
Go to file
2018-02-15 23:05:09 +01:00
include/sqlitepp Use deletion instead of unimplemented constructors 2018-02-15 23:04:06 +01:00
src Use nullptr instead of NULL 2018-02-15 23:04:59 +01:00
.gitignore Update .gitignore 2017-03-23 23:43:51 +01:00
config.mk Add version information to the Makefile and to sqlitepp.h 2017-03-27 23:36:28 +02:00
Doxyfile Move from CMake to a plain Makefile 2017-03-23 23:39:50 +01:00
LICENSE Refactoring and update. 2015-07-18 23:30:42 +02:00
Makefile Add clang-tidy tests to target checkstyle 2018-02-15 23:05:09 +01:00
README.md Update README.md 2017-03-24 00:18:56 +01:00

sqlitepp

C++ binding for the SQLite library

Dependencies

  • required dependencies
    • libsqlite3
  • optional dependencies
    • libgtest (for tests)
    • Doxygen (for the documentation)
    • Python (for linting)

Example

test.cpp

#include <iostream>
#include <memory>
#include <sqlitepp/sqlitepp.h>

int main(int argc, char** argv) {
  sqlitepp::Database database("/path/to/database.sqlite");
  database.execute("CREATE TABLE test (id, value);");
  std::shared_ptr<sqlitepp::Statement> statement = database.prepare(
      "INSERT INTO test (id, value) VALUES (:id, :value);");
  statement->bind(":id", 1);
  statement->bind(":value", "test value");
  statement->execute();
  statement = database.prepare("SELECT id, value FROM test;");
  ResultSet resultSet = statement->execute();
  while (resultSet.canRead()) {
    std::cout << "ID: " << resultSet.readInt(0) << "\t value: "
        << resultSet.readString(1) << std::endl;
    resultSet.next();
  }
}

Compile and run with:

$ g++ --std=c++11 -o test -lsqlitepp -lsqlite3 test.cpp
$ ./test
ID: 1  value: test value

For more information, see the API documentation.