MCPcopy Create free account
hub / github.com/idank/explainshell / __init__

Method __init__

explainshell/store.py:110–125  ·  view source on GitHub ↗
(self, db_path: str, read_only: bool = False)

Source from the content-addressed store, hash-verified

108 """read/write processed man pages from sqlite"""
109
110 def __init__(self, db_path: str, read_only: bool = False) -> None:
111 logger.info("creating store, db_path = %r, read_only = %s", db_path, read_only)
112 # check_same_thread=False: the default sqlite3 driver raises if a
113 # connection is used from a thread other than the one that created it.
114 # Plain Store instances are expected to be used by one caller at a
115 # time. Production web serving uses CachingStore, which supplies
116 # per-thread read-only connections around the shared lookup cache.
117 if read_only:
118 self._conn = sqlite3.connect(
119 f"file:{db_path}?mode=ro", uri=True, check_same_thread=False
120 )
121 self._conn.row_factory = sqlite3.Row
122 else:
123 self._conn = sqlite3.connect(db_path, check_same_thread=False)
124 self._conn.row_factory = sqlite3.Row
125 self._conn.execute("PRAGMA foreign_keys = ON")
126
127 @classmethod
128 def create(cls, db_path: str) -> "Store":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected