diff options
author | Robin Krahl <me@robin-krahl.de> | 2015-07-19 00:36:06 +0200 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2015-07-19 00:36:06 +0200 |
commit | e04b08fdf55e6e964f6fc2198b882d07ee463456 (patch) | |
tree | 3ef81313115b6febefba74df0a7bb7a62661df6c | |
parent | cc31ea1a42afd8d46c24753d2b489eefa29753b8 (diff) | |
download | sqlitepp-e04b08fdf55e6e964f6fc2198b882d07ee463456.tar.gz sqlitepp-e04b08fdf55e6e964f6fc2198b882d07ee463456.tar.bz2 |
Update README.md.
-rw-r--r-- | README.md | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -2,3 +2,50 @@ sqlitepp ======== C++ binding for the SQLite library + +Dependencies +------------ + + - compile dependencies + - CMake 3.0 (or later) + - libgtest + - runtime dependencies + - libsqlite3 + +Example +------- + +**test.cpp** + +```C++ +#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(); + } +} +``` + +``` +$ g++ --std=c++11 -o test -lsqlitepp -lsqlite3 test.cpp +$ ./test +ID: 1 value: test value +``` + +For more information, see the [API documentation][api]. + +[api]: http://robinkrahl.github.io/sqlitepp/ |