Read Firefox sqlite files with Python

Paul Moore p.f.moore at gmail.com
Sun Nov 5 08:39:13 EST 2017


On 5 November 2017 at 01:22, Steve D'Aprano <steve+python at pearwood.info> wrote:
> On Sun, 5 Nov 2017 04:32 am, Steve D'Aprano wrote:
>
>> I'm trying to dump a Firefox IndexDB sqlite file to text using Python 3.5.
>>
>>
>> import sqlite3
>> con = sqlite3.connect('foo.sqlite')
>> with open('dump.sql', 'w') as f:
>>     for line in con.iterdump():
>>         f.write(line + '\n')
>
>
> Never mind. I dumped the file using the sqlite3 command line tool. Thank you
> to all those who answered.
>
> The file contains three INSERT statements, the first two don't have anything
> of interest, and the third (which presumably contains all the data I'm trying
> to recover) is an opaque 600+ KB blob.
>
> Naturally. Why would you use a database as a database, when instead you could
> just dump a big ball of mud into it?

Hmm, *.sql files normally contain SQL source code (as this one does).
SQLIte databases in my experiences typically use either ".sqlite" or
".db" for the extension. Are you sure you're looking at the right
file? Alternatively I guess it's possible that Firefox creates an
in-memory database, then executes the dump.sql file to populate it,
for performance reasons.

Paul



More information about the Python-list mailing list