Access IPython's profile history (history.sqlite)

廉价感情. 提交于 2019-12-23 16:16:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!