In setup.py I've specified package_data as the following:
packages=['londontweetgrabber'],
package_dir={'londontweetgrabber': 'londontweetgrabber'},
package_data={'londontweetgrabber': ['data/data.db']},
My directory hierarchy is roughly as follows:
londontweetgrabber/
|
| docs/
| ...
| londontweetgrabber/
|
| __init__.py
| authentication.py
| data
|
| data.db
|
| README
| setup.py
What I'd like to do is use sqlite3 to load the file in data.db. Trying a variation of a solution found here (How do I use data in package_data from source code?) I can verify that the data is being loaded now, but sqlite is complaining about a table not existing that I know does. I want this data.db file to be distributed with the python package I am writing as I depend on it for what I want to do.
The code I have at the moment for loading and failing to load sqlite:
import sqlite3
import pkgutil
def get_conn():
data = pkgutil.get_data('londontweetgrabber', 'data/data.db')
print data
return sqlite3.connect(data)
Thanks