Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite & Python working together on OSX #11

Closed
bkatiemills opened this issue Dec 30, 2014 · 5 comments
Closed

SQLite & Python working together on OSX #11

bkatiemills opened this issue Dec 30, 2014 · 5 comments
Assignees

Comments

@bkatiemills
Copy link

The python script at the top of the programming lesson fails for me, with the complaint

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    cursor.execute("select site.lat, site.long from site;")
sqlite3.DatabaseError: file is encrypted or is not a database

A little googling suggests that python 2.7 uses some ancient sqlite version, that doesn't play nice with more recent ones; there are some suggestions on how to fix this on windows here and here, and something about coping with this in a virtualenv here, but this wasn't helpful to the casual OSX-using pythonista.

Does anyone know how to make Python 2.7 and SQL play nice together on OSX 10.9.5?

$ python --version
Python 2.7.8 :: Anaconda 2.1.0 (x86_64)
$ sqlite3 --version
3.7.13 2012-07-17 17:46:21 65035912264e3acbced5a3e16793327f0a2f17bb
bkatiemills added a commit to bkatiemills/sql-novice-survey that referenced this issue Dec 31, 2014
@bkatiemills
Copy link
Author

easiest fix is to just build the .db from a python script in situ - see #12 for my implementation.

@abbycabs
Copy link
Contributor

abbycabs commented Feb 1, 2015

I believe standard practice would be to include the .sql file to build the database (created using .dump > gen-survey-database.sql) then you can build the database from the file (sqlite3 survey.db < gen-survey-database.sqll).

The sql script exists here: https://github.com/swcarpentry/sql-novice-survey/blob/gh-pages/code/gen-survey-database.sql
-- Did you build the .db from this script? Or did you just copy an existing survey.db file from somewhere?

@bkatiemills
Copy link
Author

So you're saying I created the most convoluted solution to this possible? :)

You're totally right, you can generate a working .db in the way you describe - I never saw that before. Actually, I think there's some confusion surrounding loading databases, since every time I've seen / taught this lesson, I've seen it done differently. Thanks @acabunoc, I'll close this and #12 and put some clarifying comments in the notes.

@abbycabs
Copy link
Contributor

abbycabs commented Feb 2, 2015

You may still run into the same problem building the db this way! Double check first :)

@bkatiemills
Copy link
Author

looks ok to me.

rgaiacs pushed a commit to rgaiacs/swc-sql-novice-survey that referenced this issue May 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants