Browse Source

Update README.md

Robin Krahl 2 years ago
parent
commit
701de7a5a0
1 changed files with 27 additions and 29 deletions
  1. 27
    29
      README.md

+ 27
- 29
README.md View File

@@ -18,35 +18,33 @@ Example
18 18
 
19 19
 **test.cpp**
20 20
 
21
-```C++
22
-#include <iostream>
23
-#include <memory>
24
-#include <sqlitepp/sqlitepp.h>
25
-
26
-int main(int argc, char** argv) {
27
-  sqlitepp::Database database("/path/to/database.sqlite");
28
-  database.execute("CREATE TABLE test (id, value);");
29
-  std::shared_ptr<sqlitepp::Statement> statement = database.prepare(
30
-      "INSERT INTO test (id, value) VALUES (:id, :value);");
31
-  statement->bind(":id", 1);
32
-  statement->bind(":value", "test value");
33
-  statement->execute();
34
-  statement = database.prepare("SELECT id, value FROM test;");
35
-  ResultSet resultSet = statement->execute();
36
-  while (resultSet.canRead()) {
37
-    std::cout << "ID: " << resultSet.readInt(0) << "\t value: "
38
-        << resultSet.readString(1) << std::endl;
39
-    resultSet.next();
40
-  }
41
-}
42
-```
43
-
44
-```
45
-$ g++ --std=c++11 -o test -lsqlitepp -lsqlite3 test.cpp
46
-$ ./test
47
-ID: 1  value: test value
48
-```
21
+    #include <iostream>
22
+    #include <memory>
23
+    #include <sqlitepp/sqlitepp.h>
24
+
25
+    int main(int argc, char** argv) {
26
+      sqlitepp::Database database("/path/to/database.sqlite");
27
+      database.execute("CREATE TABLE test (id, value);");
28
+      std::shared_ptr<sqlitepp::Statement> statement = database.prepare(
29
+          "INSERT INTO test (id, value) VALUES (:id, :value);");
30
+      statement->bind(":id", 1);
31
+      statement->bind(":value", "test value");
32
+      statement->execute();
33
+      statement = database.prepare("SELECT id, value FROM test;");
34
+      ResultSet resultSet = statement->execute();
35
+      while (resultSet.canRead()) {
36
+        std::cout << "ID: " << resultSet.readInt(0) << "\t value: "
37
+            << resultSet.readString(1) << std::endl;
38
+        resultSet.next();
39
+      }
40
+    }
41
+
42
+Compile and run with:
43
+
44
+    $ g++ --std=c++11 -o test -lsqlitepp -lsqlite3 test.cpp
45
+    $ ./test
46
+    ID: 1  value: test value
49 47
 
50 48
 For more information, see the [API documentation][api].
51 49
 
52
-[api]: http://robinkrahl.github.io/sqlitepp/
50
+[api]: https://code.ireas.org/sqlitepp/doc/

Loading…
Cancel
Save