Blame


1 7f78ef2c 2023-12-31 op The sqlite3 module provides Hare bindings to the sqlite3 library. By
2 7f78ef2c 2023-12-31 op design, the wrapper functions resembles the underlying sqlite3 APIs so
3 7f78ef2c 2023-12-31 op that it is possible to use this module while reading the sqlite3
4 7f78ef2c 2023-12-31 op official documentation. However, it is not a perfect 1:1 mapping, as
5 7f78ef2c 2023-12-31 op the exported functions should feel nice to use in Hare and not just
6 7f78ef2c 2023-12-31 op mirorr the C APIs.
7 7f78ef2c 2023-12-31 op
8 7f78ef2c 2023-12-31 op Sample code:
9 7f78ef2c 2023-12-31 op
10 7f78ef2c 2023-12-31 op use fmt;
11 7f78ef2c 2023-12-31 op use sqlite3;
12 7f78ef2c 2023-12-31 op
13 7f78ef2c 2023-12-31 op let db = sqlite3::open("./db.sqlite3")?;
14 7f78ef2c 2023-12-31 op defer sqlite3::close(db)?;
15 7f78ef2c 2023-12-31 op
16 7f78ef2c 2023-12-31 op let stmt = sqlite3::prepare("select $foo")?;
17 7f78ef2c 2023-12-31 op defer sqlite3::finalize(stmt)?;
18 7f78ef2c 2023-12-31 op
19 8201a1c3 2023-12-31 op sqlite3::bind(stmt, "$foo", 42)?;
20 7f78ef2c 2023-12-31 op
21 8201a1c3 2023-12-31 op for (sqlite3::step(stmt)?) {
22 7f78ef2c 2023-12-31 op fmt::printfln("The answer is {}",
23 8201a1c3 2023-12-31 op sqlite3::column_text(stmt, 0))?;
24 7f78ef2c 2023-12-31 op };