MCPcopy Index your code
hub / github.com/ipython/ipython / HistoryAccessor

Class HistoryAccessor

IPython/core/history.py:207–595  ·  view source on GitHub ↗

Access the history database without adding to it. This is intended for use by standalone history tools. IPython shells use HistoryManager, below, which is a subclass of this.

Source from the content-addressed store, hash-verified

205
206
207class HistoryAccessor(HistoryAccessorBase):
208 """Access the history database without adding to it.
209
210 This is intended for use by standalone history tools. IPython shells use
211 HistoryManager, below, which is a subclass of this."""
212
213 # counter for init_db retries, so we don't keep trying over and over
214 _corrupt_db_counter = 0
215 # after two failures, fallback on :memory:
216 _corrupt_db_limit = 2
217
218 # String holding the path to the history file
219 hist_file = Union(
220 [Instance(Path), Unicode()],
221 help="""Path to file to use for SQLite history database.
222
223 By default, IPython will put the history database in the IPython
224 profile directory. If you would rather share one history among
225 profiles, you can set this value in each, so that they are consistent.
226
227 Due to an issue with fcntl, SQLite is known to misbehave on some NFS
228 mounts. If you see IPython hanging, try setting this to something on a
229 local disk, e.g::
230
231 ipython --HistoryManager.hist_file=/tmp/ipython_hist.sqlite
232
233 you can also use the specific value `:memory:` (including the colon
234 at both end but not the back ticks), to avoid creating an history file.
235
236 """,
237 ).tag(config=True)
238
239 enabled = Bool(
240 sqlite3_found,
241 help="""enable the SQLite history
242
243 set enabled=False to disable the SQLite history,
244 in which case there will be no stored history, no SQLite connection,
245 and no background saving thread. This may be necessary in some
246 threaded environments where IPython is embedded.
247 """,
248 ).tag(config=True)
249
250 connection_options = Dict(
251 help="""Options for configuring the SQLite connection
252
253 These options are passed as keyword args to sqlite3.connect
254 when establishing database connections.
255 """
256 ).tag(config=True)
257
258 @default("connection_options")
259 def _default_connection_options(self) -> dict[str, bool]:
260 return dict(check_same_thread=False)
261
262 # The SQLite database
263 db = Any()
264

Callers 2

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…