(self)
| 81 | return "<Db#%s:%s close_idle:%s>" % (id(self), self.db_path, self.close_idle) |
| 82 | |
| 83 | def connect(self): |
| 84 | if self not in opened_dbs: |
| 85 | opened_dbs.append(self) |
| 86 | s = time.time() |
| 87 | if not os.path.isdir(self.db_dir): # Directory not exist yet |
| 88 | os.makedirs(self.db_dir) |
| 89 | self.log.debug("Created Db path: %s" % self.db_dir) |
| 90 | if not os.path.isfile(self.db_path): |
| 91 | self.log.debug("Db file not exist yet: %s" % self.db_path) |
| 92 | self.conn = sqlite3.connect(self.db_path, isolation_level="DEFERRED") |
| 93 | self.conn.row_factory = sqlite3.Row |
| 94 | self.conn.set_progress_handler(self.progress, 5000000) |
| 95 | self.cur = self.getCursor() |
| 96 | self.log.debug( |
| 97 | "Connected to %s in %.3fs (opened: %s, sqlite version: %s)..." % |
| 98 | (self.db_path, time.time() - s, len(opened_dbs), sqlite3.version) |
| 99 | ) |
| 100 | |
| 101 | def progress(self, *args, **kwargs): |
| 102 | self.progress_sleeping = True |
no test coverage detected