Is there a way to use Sqlite3 with Django on Heroku?
问题:
回答1:
The cedar stack's filesystem is not readonly.
However, you still mustn't store any data on it because the filesystem is ephemeral.
Any time your application restarts, whatever you had written to your application's filesystem disappears forever.
Any time you add a dyno, the two dynos each have their own ephemeral system; any data stored by one dyno to its ephemeral filesystem is not available to the other dyno or to any additional dynos you may add later.
Sqlite3 writes data to the local filesystem. You cannot use Sqlite3 with Heroku.
Heroku provides a default PostgreSQL installation, which Heroku manages. You can use that.
You can also use any third-party-managed cloud database system, such as Amazon RDS' or Xeround's MySQL, MongoHQ's or MongoLab's MongoDB, or Cloudant's CouchDB - all of which are available as Heroku addons.
回答2:
I'm not sure when this answer became out of date, but as of at least 21 Nov 2013, sqlite3 CAN be used on heroku: https://devcenter.heroku.com/articles/sqlite3
It will work fine if you're just doing a tiny demo app, e.g. running 1 dyno and don't care that the database gets wiped at least once every 24 hours. If not, the heroku help article suggests migrating to Postgres.
Make sure the .db file is in your git directory somewhere and not in /tmp/ though, as it would be if for instance you were following the Flask tutorial app, flaskr.