Library for easy work with SQLite 3 database
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sql3/README.md

72 lines
1.9 KiB

# SQLite3 Wrapper for C++
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
```bash
sudo apt-get -y install libsqlite3-dev
```
And compile your code
```bash
g++ test.cpp ../src/* -o test.o -l sqlite3
```
## License
[APACHE 2.0](http://www.apache.org/licenses/LICENSE-2.0/)
## Support & Feedback
For support and any feedback, contact the address: marcelb96@yahoo.com.
## Contributing
Contributions are always welcome!
Feel free to fork and start working with or without a later pull request. Or contact for suggest and request an option.