4

I'm trying to modify the two database files used by Google Drive to redirect my sync folder via a script (snapshot.db and sync_conf.db). While I can open the files in certain sqlite browsers (not all) I cant get python to execute a query. I just get the message: sqlite3.DatabaseError: file is encrypted or is not a database

Apparently google is using a Write-Ahead-logging (WAL) configuration on the databases and it can be turned off by running PRAGMA journal_mode=DELETE; (according to sqlite.org) against the database, but I can't figure out how to run that against the database if python can't read it.

heres what I have (I tried executing the PRAGMA command and commiting and then reopening but it didnt work):

import sqlite3

snapShot = 'C:\Documents and Settings\user\Local Settings\Application Data\Google\Drive\snapshot.db'
sync_conf = 'C:\Documents and Settings\user\Local Settings\Application Data\Google\Drive\sync_config.db'
sync_folder_path = 'H:\Google Drive'

conn = sqlite3.connect(snapShot)

cursor = conn.cursor()
#cursor.execute('PRAGMA journal_mode=DELETE;')
#conn.commit()
#conn= sqlite3.connect(snapShot)
#cursor = conn.cursor()
query = "UPDATE local_entry SET filename = '\\?\\" + sync_folder_path +"' WHERE filename ='\\?\C:Users\\admin\Google Drive'"
print query
cursor.execute(query)

2 Answers 2

4

problem solved. I just downloaded the latest version of sqlite from http://www.sqlite.org/download.html and overwrote the old .dll in my python27/DLL directory. Works fine now.

What a nusance.

1

I don't think the journal_mode pragma should keep sqlite3 from being able to open the db at all. Perhaps you're using an excessively old version of the sqlite3 lib? What version of Python are you using, and what version of the sqlite3 library?

import sqlite3
print sqlite3.version
9
  • Python 2.7.2 and sqlite3 verson 2.6.0 but sqlite3.sqlite_version is 3.6.21
    – Jtgrenz
    Jul 12, 2012 at 17:05
  • 1
    Interesting. The version of sqlite3 bundled with python 2.7.2 should be 2.6.0. But I guess 3.6 is higher, so that ought to work. I just tried opening those two db files in my own Google Drive with python 2.7.2 (without any pragma tricks), and it worked ok.
    – the paul
    Jul 12, 2012 at 17:16
  • well the sqlite3 version bundled is 2.6.0 but the sqlite version used in the sqlite3 module is 3.6.21. At least thats what I take that to mean
    – Jtgrenz
    Jul 12, 2012 at 17:19
  • Ah. Didn't realize those were different. My sqlite_version is 3.7.4, so maybe that makes a difference in letting me open the dbs?
    – the paul
    Jul 12, 2012 at 17:21
  • 1
    According to sqlite.ord, WAL is a new feature as of 3.7. But I just updated to Python 2.7.3 to see if it would help, but It still uses the same versions.
    – Jtgrenz
    Jul 12, 2012 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.