https://github.com/beached/sqlite_helper
YASC - Yet Another Sqlite Class
https://github.com/beached/sqlite_helper
Last synced: 2 months ago
JSON representation
YASC - Yet Another Sqlite Class
- Host: GitHub
- URL: https://github.com/beached/sqlite_helper
- Owner: beached
- License: other
- Created: 2016-06-21T20:19:05.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-04-11T05:18:31.000Z (about 3 years ago)
- Last Synced: 2025-01-07T21:12:29.946Z (4 months ago)
- Language: C++
- Size: 1.84 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Sqlite Helper
Sqlite Helper is a small library to aid in using sqlite3 from C++. It provides RAII wrappers, prepared statements, and a
query iterator to iterate over each row in a result.## Installation
Currently it is a FetchContent'able cmake library. But can be installed too.
```cmake
FetchContent_Declare(
daw_sqlite_helper
GIT_REPOSITORY https://github.com/beached/sqlite_helper
)
# ....
target_link_libraries(MyTarget daw::daw-sqlite-helper)
```## Usage
#### Opening a database
```c++
auto db = daw::sqlite::database( "file.sqlite" );
```#### Querying a database
```c++
auto it = db.exec(
"SELECT colA, colB FROM tbl WHERE name=?",
"foo"
);
```#### Using query results
```c++
std::cout << "Found " << it.count( ) << " rows\n";
for( auto const & row: it ) {
for( auto const & col: row ) {
std::cout << col.name << ": " << col.value << '\n';
}
std::cout << '\n';
}
```The returned iterator can be reset to the beginning of the row set by calling `reset( )`.