MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / connect

Method connect

src/Db/Db.py:83–99  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers 15

executeMethod · 0.95
insertOrUpdateMethod · 0.95
processDelayedMethod · 0.95
getCursorMethod · 0.95
getSharedCursorMethod · 0.95
all.jsFile · 0.45
WrapperFunction · 0.45
getConnectedPeersMethod · 0.45
actionUpdateMethod · 0.45
handleGetFileMethod · 0.45
actionPexMethod · 0.45
actionListModifiedMethod · 0.45

Calls 1

getCursorMethod · 0.95

Tested by

no test coverage detected