For background, I'm trying to migrate my sqlite3 local db to a postgresql db on Heroku.
I have no problem accessing the db locally through my (Django) development server. However, when I try to push the db to Heroku, it says it can't open the file.
heroku db:push sqlite://path/to/db --confirm my-app-name
I get the following message:
Loaded Taps v0.3.23
Warning: Data in the app 'my-app-name' will be overwritten and will not be recoverable.
Failed to connect to database:
Sequel::DatabaseConnectionError -> SQLite3::CantOpenException: could not open database: unable to open database file
Most everything I've seen on Google relates to some bugs in earlier versions of Tap. Otherwise, I'm not sure what I should do here.
I've tried following the advice of this question and others about permissions, but I have full read and write access to the file and containing folder. I'm not too experienced with permissions -- do I need to switch ownership of the db to another user?
If /path/to/database is an absolute path, you need to do:
heroku db:push sqlite:///path/to/db --confirm my-app-name
Note the third slash. It could also be a permissions issue, in which case you want to either change the owner to the current user, or give at least read permission to the database (644).
I would try to save the data from sqlite3 to a fixture via dumpdata and then, after switching to postgres, load it again via loaddata.
Related
I'm a new django developer and I recently started a project, and am trying to get the database up and running.
For background: we are using a mysql database for storage, and the settings are configured for it. Using an Unbuntu DO server. I have also been using the virtual environment to run the commands below.
When we initially created the project we ran the makemigrations command, which populated the database with django tables, but not the Models, as we had not made any Models yet. I've now uploaded the Model code, however I could not make any new migrations, I got the error RuntimeError("Settings already configured").
According to this tutorial which I was following (https://www.geekinsta.com/how-to-customize-django-user-model/) some errors are normal and required me to delete and recreate the mysql database (which I did, it has the same name), and clear past migrations (the app/migrations/pycache is now empty). However I'm still experiencing the same error ("Settings already configured").
How can I fix this? I need to successfully run the makemigrations and migrate commands to populate the database. The new database and pycache are empty after I attempted the commands again. Thanks for any and all help.
I have deployed an app in Heroku using Django. The Django program uses a SQLite database db.sqlite3 on root directory to populate its page. Separately, there is also a Node.js scraper program that inserts to that database.
The problem is that the hard-refreshed webpage shows the same data even after the content of the database changed. Curiously, this does not happen when it is tested locally with python manage.py runserver. How can I fix this problem?
Thank you in advance!
For reference, here is my requirements.txt file:
Django==1.10.6
gunicorn==19.7.1
Pillow==4.0.0
selenium==3.3.1
whitenoise==3.3.0
You cannot use sqlite on Heroku.
An sqlite db is stored as a file on the local filesystem. But in Heroku the filesystem is ephemeral and is not shared between dynos. Every time you redeploy your app, or scale your process, or in your case launch a worker, you get a new filesystem with a different copy of the db file.
Use the proper Postgres support via the add-ons.
I need help switching my database engine from sqlite to mysql. manage.py datadump is returning the same error that pops up when I try to do anything else with manage.py : ImproperlyConfigured: Error loading MySQL module, No module named MySQLdb.
This django project is a team project. I pulled new changes from bitbucket and our backend has a new configuration. This new configuration needs mysql (and not sqlite) to work. Our lead dev is sleeping right now. I need help so I can get started working again.
Edit: How will I get the data in the sqlite database file into the new MySQL Database?
According to the Database setup paragraph in Django docs:
By default, the configuration uses SQLite.
If you wish to use another database, install the appropriate database
bindings...
And Get your database running page says:
If you’re using MySQL, you’ll need the MySQL-python package, version
1.2.1p2 or higher.
To use MySQL backend you need a tool that would help Django talk to the database, an adapter.
In other words, MySQL-python (aka MySQLdb) package needs to be installed.
Try the followings steps:
1. Change DATABASES in settings.py to MYSQL engine
2. Run $ ./manage.py syncdb
So I just created a new project and app for the blog. When I try and syncdb it says:
"sqlite3.OperationalError: unable to open database file"
I saw the noob FAQ and it says the possible errors are having an incorrect path or not giving apache permission to write to the folder.
Here is a dpaste with my settings.py and some terminal outputs to give you an idea of what's up.
http://dpaste.org/eQUm/
If the solution is to give apache permission to write, how would i do it? I am running the server on a personal computer on ubuntu.
You need to give the path to the database file, look at your database settings:
'NAME': '/home/vmplanet/code/blog', # Or path to database file if using sqlite3.
...which is presumably the project directory. Try /home/vmplanet/code/blog/blog.db.
I have had no troubles locally, but pushing a new project to an existing machine (one running plenty of other django apps without trouble) gave this:
OperationalError: unable to open database file
What is more perplexing is:
The sqlite file is read-write for all
This error only happens on some queries! Other's are fine.
In a fresh db after running syncdb, my views work, but /admin/ triggers this.
If I loaddata for some of my apps from data dumped from my local machine, some of the apps trigger this in my views, and others do not.
I can find no correlation between any of the things that seem to trigger this.
Why would it fail to open the database, aside from permissions?
Write access on the directory. I thought i checked that first :-/