Wednesday, December 13, 2017

Python SQLite location, version, and navigating around

I am participating in a hackathon which made it necessary for me to learn some Python. In particular, I was documenting on how to get SQLite setup as nobody seemed to get the full details. As usual, I try to go first principles on this so that I can get a better understanding.

I am using Visual Studio 2017 Community and have the Python Development workload. This made Python available to me which is great, but I also needed SQLite. The setup for SQLite is very straightforward as it is simply a matter of copying a DLL. However, big unanswered questions remain that are not really answered anywhere for a newbie like me: Where do I copy the SQLite DLL? How does the Python code find the SQLite DLL?

Long story ... but it appears that SQLite is actually bundled into Python (at least in v3.6 that I am using).

python
import sqlite3
sqlite3.version

# WTH - that is not the right version???
# Aha - found this that explains it: https://www.obsidianforensics.com/blog/upgrading-python-sqlite

sqlite3.sqlite_version

# Hmm... I wonder what other properties are available?
sqlite3.__dir__()

... and from the site above, I also upgraded to the latest version