0

I have successfully deployed my first Django app on Heroku, but there is no data in remote database I do have dump file stored, but i don't know how to restore it on Heroku, I have read docs , and there are some commands mentioned about pulling data from local database, but i don't seem to understand that, need some help thanks in advance

the database is Sqlite

Atif Shafi
  • 954
  • 1
  • 11
  • 26
  • Please add more infos. What have you tried? what are the errors you receive? https://stackoverflow.com/questions/11546151/how-to-make-db-dumpfile-in-django you can create a "dumb file" like this and than use that to create new entries in your new DB woth the load command. you just have to specify which database should be used. https://stackoverflow.com/questions/57676143/using-multiple-databases-with-django – hansTheFranz Sep 05 '21 at 09:33
  • i have created a Dump file already but how to restore it on heroku – Atif Shafi Sep 05 '21 at 09:34
  • you do not "restore" anything. you habe two databases. One that heroku gave you and one you have local. YOu neeed to transfer the data. Write a script that loads your dumb file and adds those entries to your heroku db. if you need help with the script writ the first 10 lines, post it here and show us the error or part where you are stuck. – hansTheFranz Sep 05 '21 at 09:48
  • Does this answer your question? [Prevent Django SQLite db from being overwritten while pushing to Heroku](https://stackoverflow.com/questions/23738598/prevent-django-sqlite-db-from-being-overwritten-while-pushing-to-heroku) – ChrisGPT was on strike Sep 05 '21 at 19:30
  • @hansTheFranz, I'm sure this is a typo, but please be careful. It's a _dump_ file, not a "dumb" file. You've made this typo twice. We do have an [official code of conduct](https://stackoverflow.com/conduct) and I'd hate for somebody to think you're being deliberately rude. – ChrisGPT was on strike Sep 05 '21 at 19:34
  • Atif, hansTheFranz is mostly right. There's no reason the data in your local database should match what's on Heroku. Application state can (and probably _should_) vary between environments. Note that [SQLite _cannot_ be used on Heroku due to its ephemeral filesystem](https://stackoverflow.com/q/50421061/354577). You'll have to use a client-server database like PostgreSQL and I _strongly_ urge you to use the same database in development. – ChrisGPT was on strike Sep 05 '21 at 19:38
  • but is there any way out, without changing databases, i mean i want to use SQLite , is there any way i can restore that on production @Chris, i see that i have to migrate from SQLite to Postgres, but any other way out? – Atif Shafi Sep 06 '21 at 03:13
  • "i mean i want to use SQLite"—unless you plan to use it as a read-only data source, you cannot. Any modification to data stored in SQLite will be lost frequently and unpredictably. Your database _must_ reside somewhere off your dyno, and PostgreSQL is one good option (though you could use MySQL, MongoDB, or any number of other things if you prefer). This is well-established, both here and in Heroku's official documentation. Please read the two links I provided in my comments. – ChrisGPT was on strike Sep 06 '21 at 15:45
  • To copy data you _might_ have success [using `dumpdata` and `loaddata`](https://stackoverflow.com/a/54829821/354577) but this is far from guaranteed. I've seen even trivial Django applications where this failed due to constraints that PostgreSQL enforces but SQLite does not by default. This is not a long-term solution; you really should use the same database in development and production. They're not drop-in replacements for each other. – ChrisGPT was on strike Sep 06 '21 at 15:47

0 Answers0