[Tutor] sqlite3 woes opening Moz, FFox sqlite db with only the inevitable 'DatabaseError: file is encrypted or is not a database' occurring...

Paul Smith paulrsmith7777 at gmail.com
Wed Jul 24 06:11:06 CEST 2013


title = three days lost and counting...

Thanks in advance all:

Ok- I want to work with data in FFox, specifically a sqlite db found here..

'C:\Users\Hive2\AppData\Roaming\Mozilla\Firefox\Profiles\zabt0uq4.default\places.sqlite'

...more specifically my FFox history found in a table 'moz_places'.

Running Py 2.7.5 on a windows 7-64 machine and after days of
*consulting -*google; various-boards ;stackoverflow;
py.org; sqlite.org; mingw32?(prereq. for sqlite v. 2.6.3?); sphynx?(another
prereq. for I forget); and *addressing* - possible version differences
between sqlite3 and FFoxdb; file path confirmation; db creation - query
using sqlite3(successful); etc. etc.

We end up here...

import sqlite3 as lite
import sys
import os

print ("sqlite version info1:",lite.version)##clunky version confirm
print ("sqlite version info2:",lite.sqlite_version,"\n")##clunk's cousin

mypath =
os.path.realpath("C:\\Users\\Hive2\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\zabt0uq4.default\\places.sqlite")
mydb = (mypath)## I'm trying to confirm the path to the friggin' thing
print ("This is my db path""\n"+(mydb))
con = None
con = lite.connect(mydb)
with con:
cur = con.cursor()
cur.execute("SELECT * FROM 'moz_places'")## it is a table in places.sqlite
seems apropos
print (con.fetchall()) ## print it all?
con.close()

Which produces...

Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]
on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART
================================
>>>
('sqlite version info1:', '2.6.0')
('sqlite version info2:', '3.6.21', '\n')
This is my db path
C:\Users\Hive2\AppData\Roaming\Mozilla\Firefox\Profiles\zabt0uq4.default\places.sqlite

Traceback (most recent call last):
  File "E:\pyurlseek\zedpathconfirm.py", line 15, in <module>
    cur.execute("SELECT * FROM 'moz_places'")
DatabaseError: file is encrypted or is not a database

I just want to print out the table (or anything from the FFox db just to
prove it is being opened/accessed?!)

I am sure it is a simple error but being a real newb that I am I cannot
escape the dreaded 'DatabaseError: file is encrypted or is not a database',
time and time again.

Help please

Thanks in advance,

PSmith

Additional items: no I did not have FFox open when running; yes I can
access the FFox sqlite db from 3 other programs like SQLite Expert etc. yes
I do need some sleep now so, ciao.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130724/ee307c16/attachment.html>


More information about the Tutor mailing list