Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://a4z.github.io/libsl3/
The convenient C++ interface for SQLite
https://a4z.github.io/libsl3/
sql sqlite
Last synced: 13 days ago
JSON representation
The convenient C++ interface for SQLite
- Host: GitHub
- URL: https://a4z.github.io/libsl3/
- Owner: a4z
- Created: 2015-10-06T18:16:47.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2023-05-20T18:27:02.000Z (over 1 year ago)
- Last Synced: 2024-08-01T10:21:40.098Z (3 months ago)
- Topics: sql, sqlite
- Language: C
- Homepage: https://a4z.github.io/libsl3/
- Size: 7.26 MB
- Stars: 15
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libsl3, a C++ interface for SQLite 3.x
libsl3 is designed to enable comfortable and efficient communication with a
SQLite database based on its natural language, which is SQL.libsl3 originated back at a time when C++11 was new.
It has remained stable to support existing users for quite a while, over a decade.
With the arrival of C++23, development has been restarted. The minimum required C++ standard is now C++17.
The goal is to keep the interface stable, but using a newer C++ standard might justify some breaking changes.For people seeking the old version, release v1.1.31001 preserves the original C++11 state with CMake 2.8 support.
**The full documentation for libsl3 can be found here:**
https://a4z.github.io/libsl3/## A short usage example
```cpp
#include
#include
#includeint main()
{
using namespace sl3;
// define a db
Database db(":memory:");
// run commands against the db
db.execute("CREATE TABLE tbl(f1 INTEGER, f2 TEXT, f3 REAL);");
// create a command with parameters
auto cmd = db.prepare("INSERT INTO tbl (f1, f2, f3) VALUES (?,?,?);");
//add some data
cmd.execute(parameters(1, "one", 1.1));
cmd.execute(parameters(2, "two", 2.2));
// access the data
Dataset ds = db.select("SELECT * FROM tbl;");
// Dataset is a container
assert(ds.size()==2);
// A row in a dataset is also a container
auto row = ds[0] ;
assert(row.size()==3);
// Type info for each field s available
assert ( row[0].type() == Type::Int ) ;
assert ( row[1].type() == Type::Text ) ;
assert ( row[2].type() == Type::Real ) ;
// there is also iterator access
for(const auto& row :ds) {
for (const auto& field : row) {
std::cout << field << " " ;
}
std::cout << std::endl;
}
}```
This will output
```bash
1 one 1.1
2 two 2.1
```Additional samples can be found in the tests and tests/samples subfolder.
## License
https://www.mozilla.org/en-US/MPL/2.0/