Skip to content

Instantly share code, notes, and snippets.

@gdlmx
Created July 18, 2020 02:44
Show Gist options
  • Save gdlmx/31b59b65761f3f5cb9a7045e3d943c39 to your computer and use it in GitHub Desktop.
Save gdlmx/31b59b65761f3f5cb9a7045e3d943c39 to your computer and use it in GitHub Desktop.
Export Firefox bookmarks
import sqlite3, pandas as pd
conn = sqlite3.connect('places.sqlite')
tinfo= pd.read_sql_query("SELECT * FROM pragma_table_info('moz_places')", conn)
cols = [ 'p.'+c for c in tinfo.name if 'id' not in c ]
tinfo = pd.read_sql_query("SELECT * FROM pragma_table_info('moz_bookmarks')", conn)
cols += [ 'b.'+c for c in tinfo.name if 'id' not in c and 'title' not in c ]
tbmk = pd.read_sql_query("SELECT {0} FROM moz_bookmarks b INNER JOIN moz_places p ON b.fk = p.id".format( ', '.join(cols) ),
conn);
for c in tbmk:
if 'date' in c or c.startswith('last'):
tbmk[c] = pd.to_datetime(tbmk[c], unit='us', errors='coerce')
tbmk.to_excel('places.xlsx')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment