Is there way to dump heroku postgres database and import the data into my local SQLite database?
I tried using https://github.com/ludicast/yaml_db and heroku db:pull with no success. I am developing on Windows 7.
Please read through
https://devcenter.heroku.com/articles/heroku-postgres-import-export
and follow those to export.
Though the above link can be used to export alone, it does not have solution for the entire process. So you can look on the similar question and its solution
Copy a heroku postgres db to a local sqlite db
Related
I am trying to import data to a postgres database in heroku. I am able to upload the correct schema to heroku by using the command:
heroku pg:psql -a [app name] < db/structure.sql
so now when I run heroku pg:psql and connect to my database I can run:
\dt
and it lists all of the tables that I want. However, only the schema is uploaded, not the actual data. I have looked over a bunch of different ways to upload databases to heroku, but have been unable to get any to work. I was wondering if there is an easy way to import local csv data to heroku. Locally, I can run:
sqlite3 development.sqlite3
.mode csv
.import [table name] [filename]
And it imports the data that I want. Is there a similar way to do this for heroku databases? I know that heroku uses postgres and not sqlite3, but since I was able to load the schema easily, I thought there might be an easy way to upload data. This is my first ruby on rails project I've ever attempted to publish, so any guidance would be appreciated!
Thanks!
Upload your csv to heroku and run
COPY zip_codes FROM '/path/to/your_file.csv' DELIMITER ',' CSV;
in pg shell
Look https://gist.github.com/jboesch/5605747, Importing csv to heroku postgres how you can do it
I'm trying to create a new record through the rails console but I'm getting the following error:
PG::ConnectionBad: FATAL: database "my_database_development" does not exist
I've recently changed from Sqlite3 to PG to be able to deploy to Heroku. Is this what is giving the error?
Thanks a lot!
It looks like you have not yet run
rake db:create
This will "create" the databases on your PostgreSQL server. A step that you didn't have to do with SQLite, but Postgres requires it. As TK-421 said, make sure that your database.yml is configured for your OS and Postgres, not SQLite.
Here is a (possibly outdated) Railscast on the topic.
http://railscasts.com/episodes/342-migrating-to-postgresql
Is this running locally, or on Heroku? In config/database.yml, the local user you specify will need to have CREATEDB privileges (as a superuser, for example).
There's a little more configuration required in this case than for SQLite. Google will show you a bunch of tutorials specific to your OS.
If you see this problem in production on heroku, start the console like this:
rails console production
If you have that problem in development on your machine, check your config/database.yml. It is points to a local development database that does not exist.
So I am trying to push a SQLite3 database to Heroku which I thought used to be possible, but reading here and here imply that it may not be (the below doesn't work).
heroku pg:push sqlite://db/development.sqlite3 HEROKU_POSTGRESQL_OLIVE_URL
! LOCAL_SOURCE_DATABASE is not a valid database name
Was this changed when Heroku switched the syntax to pg:push from db:push or was it never possible?
Given that it's not possible is the solution to migrate any data from SQLite3 to local postgres and then push to Heroku?
Heroku uses a read-only filesystem, which means that local file system based databases like SQLite3 aren't compatible with their infrastructure. And to my knowledge it has never been possible to push from a SQLite3 db directly to Postgres on Heroku.
You should migrate your data to a local Postgres database and push from there.
For what it's worth, it was possible to db:push from a local sqlite3 database to Heroku postgres, but there was a timestamp bug in any version of Ruby after 1.9.3.
Switching to postgres on local will end up being easier than messing with RVM and Gemfiles whenever you want to send data up to the server.
I have created the test, production and development databases on server manually but not able to figure out, how to transfer data from local myapp_development database to myapp_production database on the server ?
I searched and found this How to move Rails app + pgsql database from localhost to my server?, capistrano is giving me lot of errors and I am sure there must be a standard Rails way or postgres way to do this as exporting data as dump and again importing it though I may have to do it if I can't find anything better.
You can dump the database using pg_dump then scp the database dump up to the database and run it on the server using psql databse_name < database.dump
I use yaml_db gem. It can dump your data into a file and then load it back into the database. It's written using activerecord so it works with most databases.
URL: https://github.com/ludicast/yaml_db
rake db:data:dump -> Dump contents of Rails database to db/data.yml
rake db:data:load -> Load contents of db/data.yml into the database
Prefix the commands with RAILS_ENV=development or RAILS_ENV=production to choose target and destination scheme.
I've a Rails 2.1.2 App hosted on site 5.
This App is running since 2 years and I want to migrate the site on heroku.
No pb to install the site on heroku, but what about the data?!
What is the best strategy to export from site 5 (I've phpMyAdmin) and then import to heroku?
Thanks
Export the data to your local system as SQL dump from phpMyAdmin, import it into your development database and then use the built-in Heroku db tools (based on Taps) to import into production:
heroku db:push