Warning
This documentation is for an old version of IPython. You can find docs for newer versions here.
History related magics and functionality
Bases: object
Dummy DB that will act as a black hole for history.
Only used in the absence of sqlite
Bases: sqlite3.Error
Bases: IPython.config.configurable.Configurable
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.
Create a new history accessor.
Parameters: | profile : str
hist_file : str
config : :
|
---|
Retrieve input by session.
Parameters: | session : int
start : int
stop : int
raw : bool
output : bool
|
---|---|
Returns: | An iterator over the desired lines. Each line is a 3-tuple, either : (session, line, input) if output is False, or : (session, line, (input, output)) if output is True. : |
Get lines of history from a string of ranges, as used by magic commands %hist, %save, %macro, etc.
Parameters: | rangestr : str
raw, output : bool
|
---|---|
Returns: | Tuples as :meth:`get_range` : |
get info about a session
Parameters: | session : int
|
---|---|
Returns: | (session_id [int], start [datetime], end [datetime], num_cmds [int], : remark [unicode]) : Sessions that are running or did not exit cleanly will have `end=None` : and `num_cmds=None`. : |
Get the last n lines from the history database.
Parameters: | n : int
raw, output : bool
include_latest : bool
|
---|---|
Returns: | Tuples as :meth:`get_range` : |
Connect to the database, and create tables if necessary.
Search the database using unix glob-style matching (wildcards * and ?).
Parameters: | pattern : str
search_raw : bool
raw, output : bool
n : None or int
unique : bool
|
---|---|
Returns: | Tuples as :meth:`get_range` : |
Overridden by HistoryManager to dump the cache before certain database lookups.
Bases: IPython.core.history.HistoryAccessor
A class to organize all history-related functionality in one place.
Create a new history manager associated with a shell instance.
Close the database session, filling in the end time and line count.
Retrieve input by session.
Parameters: | session : int
start : int
stop : int
raw : bool
output : bool
|
---|---|
Returns: | An iterator over the desired lines. Each line is a 3-tuple, either : (session, line, input) if output is False, or : (session, line, (input, output)) if output is True. : |
Give the current session a name in the history database.
Get a new session number.
Clear the session history, releasing all object references, and optionally open a new session.
Store source and raw input in history and create input cache variables _i*.
Parameters: | line_num : int
source : str
source_raw : str, optional
|
---|
If database output logging is enabled, this saves all the outputs from the indicated prompt number to the database. It’s called by run_cell after code has been executed.
Parameters: | line_num : int
|
---|
Write any entries in the cache to the database.
Bases: threading.Thread
This thread takes care of writing history to the database, so that the UI isn’t held up while that happens.
It waits for the HistoryManager’s save_flag to be set, then writes out the history cache. The main thread is responsible for setting the flag when the cache size reaches a defined threshold.
This can be called from the main thread to safely stop this thread.
Note that it does not attempt to write out remaining history before exiting. That should be done by calling the HistoryManager’s end_session method.
return an empty list in the absence of sqlite
A decorator which wraps HistoryAccessor method calls to catch errors from a corrupt SQLite database, move the old database out of the way, and create a new one.
Turn a string of history ranges into 3-tuples of (session, start, stop).
Examples
list(extract_input_ranges(“~8/5-~7/4 2”)) [(-8, 5, None), (-7, 1, 4), (0, 2, 3)]