37 lines
660 B
C++
37 lines
660 B
C++
#include <litedb.h>
|
|
|
|
litedb::litedb(std::string &db_name) : stmt(nullptr), db(nullptr)
|
|
{
|
|
this->_db_path_name = std::move(db_name);
|
|
}
|
|
|
|
litedb::~litedb()
|
|
{
|
|
if (this->stmt)
|
|
sqlite3_finalize(this->stmt);
|
|
|
|
if (this->db)
|
|
sqlite3_close_v2(this->db);
|
|
}
|
|
|
|
Status litedb::litedb_open()
|
|
{
|
|
|
|
if (this->_db_path_name.empty())
|
|
{
|
|
return Status::STATUS_INNER_ERR;
|
|
}
|
|
|
|
if (this->db)
|
|
{
|
|
return Status::STATUS_OK;
|
|
}
|
|
|
|
int ret = sqlite3_open_v2(this->_db_path_name.c_str(), &this->db, 0, nullptr);
|
|
if (ret != SQLITE_OK)
|
|
{
|
|
return Status::STATUS_INNER_ERR;
|
|
}
|
|
|
|
return Status::STATUS_OK;
|
|
} |