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.
| 136 | |
| 137 | |
| 138 | class HistoryAccessor(HistoryAccessorBase): |
| 139 | """Access the history database without adding to it. |
| 140 | |
| 141 | This is intended for use by standalone history tools. IPython shells use |
| 142 | HistoryManager, below, which is a subclass of this.""" |
| 143 | |
| 144 | # counter for init_db retries, so we don't keep trying over and over |
| 145 | _corrupt_db_counter = 0 |
| 146 | # after two failures, fallback on :memory: |
| 147 | _corrupt_db_limit = 2 |
| 148 | |
| 149 | # String holding the path to the history file |
| 150 | hist_file = Unicode( |
| 151 | help="""Path to file to use for SQLite history database. |
| 152 | |
| 153 | By default, IPython will put the history database in the IPython |
| 154 | profile directory. If you would rather share one history among |
| 155 | profiles, you can set this value in each, so that they are consistent. |
| 156 | |
| 157 | Due to an issue with fcntl, SQLite is known to misbehave on some NFS |
| 158 | mounts. If you see IPython hanging, try setting this to something on a |
| 159 | local disk, e.g:: |
| 160 | |
| 161 | ipython --HistoryManager.hist_file=/tmp/ipython_hist.sqlite |
| 162 | |
| 163 | you can also use the specific value `:memory:` (including the colon |
| 164 | at both end but not the back ticks), to avoid creating an history file. |
| 165 | |
| 166 | """).tag(config=True) |
| 167 | |
| 168 | enabled = Bool(True, |
| 169 | help="""enable the SQLite history |
| 170 | |
| 171 | set enabled=False to disable the SQLite history, |
| 172 | in which case there will be no stored history, no SQLite connection, |
| 173 | and no background saving thread. This may be necessary in some |
| 174 | threaded environments where IPython is embedded. |
| 175 | """ |
| 176 | ).tag(config=True) |
| 177 | |
| 178 | connection_options = Dict( |
| 179 | help="""Options for configuring the SQLite connection |
| 180 | |
| 181 | These options are passed as keyword args to sqlite3.connect |
| 182 | when establishing database connections. |
| 183 | """ |
| 184 | ).tag(config=True) |
| 185 | |
| 186 | # The SQLite database |
| 187 | db = Any() |
| 188 | @observe('db') |
| 189 | def _db_changed(self, change): |
| 190 | """validate the db, since it can be an Instance of two different types""" |
| 191 | new = change['new'] |
| 192 | connection_types = (DummyDB,) |
| 193 | if sqlite3 is not None: |
| 194 | connection_types = (DummyDB, sqlite3.Connection) |
| 195 | if not isinstance(new, connection_types): |
no outgoing calls
no test coverage detected