I am creating a Flask website that uses Sqlite3 and would like to deploy it on Heroku. I have read about how Heroku doesn't support Sqlite3 because of it's stack system and how it resets dynos/clears disk at least every 24hrs. That is not important to me and I only need to access updates that were made to my DB in the past 24 hours. My app functions fine on Heroku when I run a script that updates the DB and then push to heroku. My worker script never updates on Heroku, however, and my web app only displays the updated data from my last local machine push. Is there any way to get this to work?
Asked
Active
Viewed 56 times
0
-
1why stick to sqlite3? you can use postgresql – sahasrara62 Apr 23 '21 at 22:56
-
@sahasrara62 I would just like to get my project running ASAP. I have my schema in sqlite3 setup and my project works. If this is not possible at all I would like to know why it isn't. I am new to this and don't want to mess up switching to postgresql. – Idk Apr 23 '21 at 23:06
-
No, there is no way to effectively use SQLite on Heroku. Your database can be reset to whatever was committed at any time. This is well documented, both on Heroku's site and in questions here. Even if you are just reading the SQLite database on Heroku, having a committed database is a design flaw. Your database should (probably) not be committed at all. Data ≠ application code. – ChrisGPT was on strike Apr 24 '21 at 02:46
-
@Chris Thanks, that definitely helps! I saw this documented on Heroku but didn't quite understand why it wouldn't wipe the DB completely (you clarified this for me by saying it resets to whatever was committed). – Idk Apr 24 '21 at 07:23
-
if you are using table schema through sql query then you need to change it accordingly, otherwise if you are using flask sqlalchemy and model class then flask migrate can help yuo to create tables – sahasrara62 Apr 24 '21 at 10:02
-
@sahasrara62 I am using flask-sqlalchemy and the the model class. I will look into flask migrate, thanks. – Idk Apr 24 '21 at 19:26
-
As you are doing db.create_all to create all table , with migrate ,you will need to do 'flask db init flask db migrate flask db upgrade' – sahasrara62 Apr 25 '21 at 09:35