blob: d45d7d7030eaa98939df6be40060cbe2542c8d36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
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**
```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/
|