sqlite3.h 651 B

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