marcelb
8f19567a59
|
1 month ago | |
---|---|---|
.vscode | 1 month ago | |
example | 1 year ago | |
lib | 1 month ago | |
src | 1 month ago | |
test | 1 month ago | |
.gitignore | 3 months ago | |
LICENSE | 1 month ago | |
README.md | 1 month ago |
README.md
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:
#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
sudo apt-get -y install libsqlite3-dev
And compile your code
g++ test.cpp ../src/* -o test.o -l sqlite3
License
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.