diff options
author | Robin Krahl <me@robin-krahl.de> | 2017-03-24 00:18:56 +0100 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2017-03-24 00:18:56 +0100 |
commit | 701de7a5a0890003ccd9ce0ba6eff322ed791009 (patch) | |
tree | 9ec8abc8ad9b10d66e502cf1bacd4a722d6160a4 | |
parent | d1a9a57795d80123838117a19be1ff2c5898194d (diff) | |
download | sqlitepp-701de7a5a0890003ccd9ce0ba6eff322ed791009.tar.gz sqlitepp-701de7a5a0890003ccd9ce0ba6eff322ed791009.tar.bz2 |
Update README.md
-rw-r--r-- | README.md | 56 |
1 files changed, 27 insertions, 29 deletions
@@ -18,35 +18,33 @@ 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 -``` + #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][api]. -[api]: http://robinkrahl.github.io/sqlitepp/ +[api]: https://code.ireas.org/sqlitepp/doc/ |