Question

I am writing a simple Python script that fetches data from a sqlite3 database. I am experiencing the following error:

sqlite3.DatabaseError: file is encrypted or is not a database

I found out that this error is caused by a version problem of sqlite3. On the Mac (10.6.8) I need to use for now the SQLite version is 3.6.12. I downloaded SQLite 3.7.16.2 and can open the database with that version. But how can I tell Python to use the non-standard SQLite version in that script?

I am using

Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin

Eventually I will use Ubuntu for that project but for testing purposes I need to run the script on that particular Mac configuration. Thanks for helping!

Was it helpful?

Solution

Another option is to install a newer Python. For instance, the current python.org Python 2.7.4 installers (available here) ship with SQLite 3.7.13.

$ /usr/local/bin/python2.7
Python 2.7.4 (v2.7.4:026ee0057e2d, Apr  6 2013, 11:43:10)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version_info (3, 7, 13)

OTHER TIPS

You can use DYLD_LIBRARY_PATH environment variable to place the directory of a replacement sqlite .dyld earlier in the search path. See man dyld. This is similar to LD_LIBRARY_PATH on Linux.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top