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/lib/sqlite3.hpp

52 lines
839 B

#ifndef _MARCELB_SQLITE3_
#define _MARCELB_SQLITE3_
#include <stdio.h>
#include <sqlite3.h>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include <mutex>
using namespace std;
namespace marcelb::SQlite3 {
class SQLite3 {
mutex io;
sqlite3* db;
string path;
bool keepOpen;
bool open();
bool close();
public:
/**
* Open SQLite3 database
* path - path to the file
* _keepOpen - true: keeps the file open, false: opens it when needed
*/
SQLite3(const string path, bool _keepOpen = false);
/**
* Make a request to the database
*/
map<string, vector<string>> query(const string& sql_command, const vector<string>& values);
/**
* Close the database and destroy the object
*/
~SQLite3();
};
}
#endif