I have a very small, simple sqlite database, and several python scripts to access the database. I want to run these scripts using Heroku, but it seems that Heroku doesn’t support sqlite3.
I have tried adding the line
sqlite3==3.0
to my requirements.txt file before running
pip install -r requirements.txt
but it says it can’t find sqlite3.
What is the easiest, most lightweight way to be able to query my sqlite database on Heroku?
- Do I need to convert the sqlite database? If so, how do I do that?
-
If I’m not allowed to
import sqlitein python on Heroku, what is the alternative package I need to use and how do I change my python code which calls execute statements likeSELECT * FROM table
I find that the Heroku documentation assumes that the user has a bit more expertise. Also, it seems from other stackoverflow, blog posts that folks where somehow able to use sqlite3 with Ruby.
The external modulename would be
pysqlite.However, Heroku runs Python 2.7 and if
import sqlite3is not supported, Heroku will not have the pre-requisite sqlite C libraries installed. I thus suspect that loading thepysqlitemodule will not work either.Note that there is really no point in using sqlite on the Heroku platform, as the filesystem is ephemeral; every time your app starts you have a clean slate and any writes performed by your app disappear once done. Since sqlite can only write to the local filesystem, this means the database will be gone the next time you start your app. See Using Sqlite3 on Heroku Cedar stack.