Closed Twix53791 closed 3 months ago
Why does this need to change the database? You should be using whatever strptime format you desire given last_atime
from the unix epoch when generating completion entries for your tooling.
Well, if you find a way to be as fast as sqlite3 reading the database, I am hearing... Currently, my script takes 0.2 sec to display the list of a 10 000 lines history in fzf, and it is because I want a beautifull colored output, it could be faster. The history is growing fast, in a couple of years, i will have much more entries, and the time will not increase much, because sqlite3 and fzf are almost as much fast as reading 1 million entries than 1000. CLI programs loose all their benefits when they are slow. Whithout the lighting speed of sqlite3+fzf, rather use the native qutebrowser feature...
But I think everyone has to recognize the native qutebrowser history display is not practicable. You can't search into the all database straightaway, you can't search for an old date ; and I was missing my old Firefox. But with my fzf tool, it is firefox which is old-fashioned! Realtime search in as much as entries I will have in my entire life, search indiscriminately the page title, the date, the url, can open in one key dozens of urls... Just amazing.
Before, I tried two differents ways, maybe there is a third, I am not a pro dev and not good at python...
The history database format is an implementation detail. If external tools can work with it, that's nice, but this isn't guaranteed. As such, I don't think it's reasonable to add data to it that only caters to external tools.
@Twix53791 you can use sqlite to convert the unix time in the DB to a string format. Eg select datetime(last_atime, 'unixepoch') from CompletionHistory
.
In my case doing time sqlite3 history.sqlite "select datetime(last_atime, 'unixepoch') from CompletionHistory" | wc -l
for a 300k table I'm seeing 100ms for datetime(...)
vs 60ms for just the plain column.
Thanks a lot @toofar ! I did'nt know this possibility, its amazing! No need so to change the database history format. I updated my plugin.
Hi,
I am just leaving here a small stone in case of oneday, some of the devs of qutebrowser think about redesigning the database history.
I wrote a small plugin to display the browser history with fzf in a pop up window. It is fast and practicable. Very fast.
But to reach this speed, it needs to have minimal operations to make. The problem is that the qutebrowser history database store the time in an epoch time format. It is not practical to search for a date: a year, a month, a day... And rebuilding the time in a human readable format from the epoch time in the plugin obviously slows it a lot, especially when the history contains thousands of urls.So, I made a patch modifying history.py file in qutebrowser, adding to the table 'CompletionHistory' of history.sqlite the column 'human_time', which stote the time in a format "%Y %B %d %H:%M:%S". So you can limit the scope of the history display by year, then month, then day, then the time...The problem with this modification is than it breaks if the history database already exist, because the column 'human_time' doesn't exist. I tried a bit to find a way letting qutebrowser to add the column if it doesn't exist, but it seems complicated. So, it is not possible to implement the change in qutebrowser without broking the config of everyone or making important changes in sql.py. That's why I made a patch, and a plugin.EDIT: thanks to @toofar, I learned than sqlite3 has a tool to output an epoch time format in a human readable form.
For those interested, I also made a patch for tabbedbrowser.py recording the last 100 closed tabs in a file in the same format, with a human readable time format, to use it also with fzf.