| 93 | sqliteOperation::~sqliteOperation() { close(); } |
| 94 | |
| 95 | bool sqliteOperation::connect() { |
| 96 | if (dbPtr != NULL) { |
| 97 | std::cerr << "Connection exists" << std::endl; |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | int flags = SQLITE_OPEN_READWRITE; |
| 102 | if (!isFileExists(dbPath)) flags |= SQLITE_OPEN_CREATE; |
| 103 | |
| 104 | if (SQLITE_OK != sqlite3_open_v2(dbPath.c_str(), &dbPtr, flags, 0)) return false; |
| 105 | |
| 106 | dbCache = spatialite_alloc_connection(); |
| 107 | spatialite_init_ex(dbPtr, dbCache, 0); |
| 108 | |
| 109 | sqlitePackage::execSql(dbPtr, "PRAGMA foreign_keys = ON;"); |
| 110 | return true; |
| 111 | } |
| 112 | |
| 113 | bool sqliteOperation::initialize() { |
| 114 | if (NULL == dbPtr) { |
no test coverage detected