This is a simple C++ wrapper around the SQLite3 database, designed to facilitate database operations while managing connections and queries efficiently. The wrapper utilizes modern C++ features, including mutexes for thread safety.
## Features
- **Simple Interface**: Easy to use API for opening databases and executing queries.
- **Thread Safety**: Uses mutexes to ensure safe access in multithreaded environments.
- **Flexible Connection Management**: Option to keep the database connection open or close it after use.
## Installation
To use this SQLite3 wrapper in your C++ project, include the header file `sqlite3.hpp` in your project directory. Ensure you have the SQLite3 library installed and linked to your project.
## Usage
### Example
Here's a basic example demonstrating how to use the SQLite3 wrapper:
```cpp
#include <iostream>
#include "../lib/sqlite3.hpp" // Adjust the path as necessary
using namespace marcelb::SQlite3;
int main() {
try {
SQLite3 mydb("../example/example.db", false);
auto res = mydb.query("SELECT * FROM Tab1 WHERE id > ?", {"3"});
for (const auto& i : res) {
for (const auto& j : i.second) {
std::cout <<i.first<<":"<<j<<std::endl;
}
}
} catch (const std::string& err) {
std::cout <<err<<std::endl;
}
return 0;
}
```
### Compile
Install libsqlite3-dev, is a C library that implements an SQLite database engine