问题
When I restart IPython, I can access the input from my last session by pressing the up- and down-keys. I found that the history specific to a profile is saved in ~/.config/ipython/profile_profilename/history.sqlite.
Is there a way to access this history in the same easy fashion as the %history command?
The IPython reference describes the feature here: http://ipython.org/ipython-doc/dev/interactive/reference.html#readline-based-features
This guy has the same question, but they don't find a 'direct' solution: http://python.6.n6.nabble.com/Logging-in-new-IPython-td1665151.html
回答1:
I'm assuming you mean a tool to access your history from the outside IPython, perhaps from the command line?
The API to do it is already there - see the class IPython.core.history.HistoryAccessor (source code). There's an example script (updated link) showing how you can use it to dump a session from the database. But we haven't yet made an application around that. If you're interested in it, you could work on that - see our list of potential projects for contributors to start.
来源:https://stackoverflow.com/questions/12261492/access-ipythons-profile-history-history-sqlite