sqlite3.h 656 B

12345678910111213141516171819202122232425
  1. #pragma once
  2. #include "base/define.h"
  3. #include "base/error.h"
  4. #include <vector>
  5. #include <map>
  6. #define SQLITE_RESULT std::vector<std::map<std::string, std::string>>
  7. namespace ylib
  8. {
  9. class sqlite3:public ylib::error_base
  10. {
  11. public:
  12. sqlite3();
  13. ~sqlite3();
  14. bool open(const std::string& filepath,const std::string& username ="",const std::string& password = "");
  15. void close();
  16. bool exec(const std::string& sql);
  17. bool query(const std::string& sql, std::vector<std::map<std::string, std::string>>& data);
  18. int64 count(const std::string& sql);
  19. bool is_open() { return m_db != nullptr; }
  20. int64 last_insert_id();
  21. private:
  22. void* m_db;
  23. };
  24. }