Restoring the History.db SQLite3 databases from Time Machine will overwrite existing files, if that matters.
I wrote a short Zsh script that generates a CSV based on the history found in separate tables within History.db. If you select that written CSV on your Desktop after the script runs, you can use Apple's QuickLook (spacebar) to see a convenient tabular view of your history by date, title, and link. Where titles are not found, Unavailable will be substituted.
Source:
--------
#!/bin/zsh
: <<'COMMENT'
Generate a CSV document with headers showing current Safari History
database content. You can view the columnar CSV in a scrollable QuickLook window,
or load it into a spreadsheet
Reference: http://2016.padjo.org/tutorials/sqlite-your-browser-history/
Usage in Terminal:
./sql_dtu.zsh > ~/Desktop/hist.csv
VikingOSX, 2020-07-16, Apple Support Communities, No warranties expressed or implied.
COMMENT
sqlite3 -header -csv $HOME/Library/Safari/History.db \
"SELECT DISTINCT
datetime(visit_time + 978307200, 'unixepoch', 'localtime') AS visit_time,
coalesce(nullif(title,''), 'Unavailable') as title, url
FROM
history_visits
INNER JOIN
history_items ON
history_items.id = history_visits.history_item;"
exit 0
Save this script on your Desktop as sql_dtu.zsh. Launch the Terminal application and enter the following:
cd ~/Desktop
chmod +x ./sql_dtu.zsh
./sql_dtu.zsh > ~/Desktop/hist.csv
Now, you can quit the Terminal, select hist.csv on your Desktop, and just press the space bar to view it.