Heroku database push operation - sql-server

To load a database which runs now on the my computer, SQL Server 2012 and Windows, I have installed Git Bash, taps and Heroku.
Now, whenever I wrote the command
heroku db:push --app myapp
it gives the same error
Invalid database ur
I think I miss something, I have not declared which database should be pushed to the Heroku.
Can you help me with this problem ? how can I use heroku db:push, are there any other steps like creating something ? Why I get this error ? Maybe you will say that "have you read documentation or have you searched google?", Yes
EDIT: What I have know is
Local database
Server name Heroku database
Database name application name
username | or windows authentication postgres database
password | username and password
aws address
Should I put/load some file/gem into the Git ?
EDIT 2:
I have test this command but it gives other error.
heroku db:push postgres://localdbUSERNAME:localdbpassword#localdbDATABASENAME/localdbSERVERNAME --app myapp
Error
Failed to connect to database:
Sequel::AdapterNotFound -> LoadError: cannot load such file -- pg

Heroku db:push does not work with SQL Server, it works with MySQL and/or Postgres. You'll need to switch to running one of these database servers, run your migrations/seeds and then use heroku db:push to push your local database to Herokul

Related

How to transfer development database to production?

I made a Sinatra app and now I'm trying to deploy it to Heroku.
My app works with PostgreSQL database. There is data in my tables that I scraped during development. It is rendered just fine when I run it locally. However, when I deploy my app, my records do not get transferred. I know this behavior is normal, but I can't find how to transfer my records to production (database is set up correctly, you can add content through forms interactively).
This is my environment.rb:
configure :production, :development do
db = URI.parse(ENV['DATABASE_URL'] || 'postgres://localhost/lakesare')
ActiveRecord::Base.establish_connection(
:adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
:host => db.host,
:username => db.user,
:password => db.password,
:database => db.path[1..-1],
:encoding => 'utf8'
)
end
I have tried
heroku pg:push $my_db_name HEROKU_POSTGRESQL_OLIVE_URL
and it ran successfully, but my records are still not present in production db. Did I do something wrong?
I would use seeds.rb kind of thing, but how to configure it in Sinatra?
If you had a seeds file you could do heroku run ruby seeds.rb. That is assuming that the seeds file is in the root of your application. You can run pretty much any command that you can run locally on the heroku servers by prepending it with heroku run.
The only solution that worked for me is to write a few functions that fill up your database, add them to seeds.rb in db folder, deploy this to Heroku and run
heroku run rake db:schema:load
heroku run rake db:seed

Heroku. Django. South. Database column does not exist

I am new to Heroku. I just migrated my django models using south:
sudo heroku run python manage.py migrate
I get the message "Nothing to migrate" in all of my six apps.
Then when I try to visit the website I get the error:
ProgrammingError "column X does not exist".
Everything works fine locally. What should I do, drop the database and recreate it again? If that is the answer, how do I do that on Heroku?
Thanks for you help.
To drop the database on heroku, run:
heroku pg:psql
as per https://devcenter.heroku.com/articles/heroku-postgresql#pg-psql.
Then do:
drop database <database name>;
create database <database name>;
Then you can try and run your migrations again.

GAE Upload Download Data / Import Data to localhost for testing on my dev server

I needed to test some changes on my local dev server before pushing to production. Doing so required having the full dataset on my local machine.
A colleague directed me to:
https://developers.google.com/appengine/docs/python/tools/uploadingdata?csw=1
I downloaded the data using an administrator's username and password, but unfortunately, I was unable to upload the data to my localhost "dev" app engine server.
Ran this command from the commandline:
appcfg.py upload_data --filename=../data/data1.dat --url=http://localhost:9080/_ah/remote_api ./
Where:
9080 was my app port on my localhost copy of the app
I was running this command from my app directory
Had the downloaded data stored in relative directory
../data/data1.dat
Received this error:
raise _ToDatastoreError(err)
google.appengine.api.datastore_errors.BadRequestError: app "dev~appname" cannot access app "appname"'s data
UPDATE: It seems that the answer was as simple as adding the following to my upload_data call:
--application="dev~appname"
Thanks #DavidBennett.
ORIGINAL ANSWER: (which also works)
After a ton of searching on SO and code.google.com, the solution I found that worked was a comment on this question:
devappserver2, remote_api, and --default_partition
I used my original command as described in the question:
appcfg.py upload_data --filename=../data/data1.dat --url=http://localhost:9080/_ah/remote_api ./
The username and password I entered when prompted were my apps username (in my case, my email) and the corresponding password. (If that doesn't work you might want to try blank or test#example.com based on other comments I've read, but have not tested that theory.)
I also restarted my app engine with the following flag: (don’t forget to remove the flag the next time you restart the server) (You might want to try without using this flag, since I can’t confirm that it affects anything - I’m including it here, since it was a setting that I used.)
--clear_datastore=yes
The commenter recommends to delete “dev~” in your local server code on line 84 in this file:
google/appengine/tools/devappserver2/application_configuration.py, line 84
Where:
that base directory 'google' is located inside of:
/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
assuming your GoogleAppEngineLauncher.app directory is in your Applications directory on your Mac
IMPORTANT: Restart your local app engine server for the changes to take effect.

Easy way to push postgres db to heroku in Win7? problems with db:pull and pg:transfer

Using Rails 3.2.2, finishing up my migration from sqlite to postgres 9.2.
Used answer in this tutorial as a guide to install postgres and got stuck on Step 11 where it asks run heroku db:pull where I get:
Failed to connect to database: Sequel::AdapterNotFound -> LoadError: cannot load such file --pg
I dug deeper and found db:pull (taps gem) is deprecated and came across a few recommendations for pg:transfer. Installed pg:transfer, but I get the impression it may be *nix only(?) as if I run: heroku pg:transfer it returns:
Heroku client internal error. No such file or directory - .env (Errno:ENOENT)
If I do pg:transfer with -f and -t it gives me:
'env' is not recognized as an internal or external command, operable program or batch file which means it isn't bound to path or doesn't exist as a command in windows.
Any thoughts on above errors?
Resolved by using pg:backups gem, which was recommended as the replacement for taps in the Heroku docs. I used this guide and uploaded my dump to dropbox for Heroku to pick it up.
Here's my exact list of steps and cmds:
Added pgbackups from heroku.com add-ons to my instance.
heroku pgbackups:capture DATABASE (this just backs up your heroku db)
pg_dump -h localhost -U <pg username> -Fc dbname > dbname.dump
Moved dbname.dump into a folder on my dropbox
In Dropbox, right-click on dbname.dump => "Share link"
Cancel the sharing dialogue pop-up, right-click on "Download button", Copy Link Address (Chrome)
heroku pgbackups:restore DATABASE <paste dropbox download link here>
Dropbox trickiness: don't use the file link provided by Dropbox since it's an html redirect and will cause pg:restore to fail, even though the extension ends in .dump
Instead, navigate to your dropbox page and "right-click copy link address" on the Download button. That's the address you use in your pgbackups:restore (should be something like db.dump?token=<long random string>)
A bit clunky, but got the job done. If you know a better way please let me know!
You need to make a .env file containing something like:
DATABASE_URL=postgres://localhost/myapp_development
References:
https://github.com/ddollar/heroku-pg-transfer
https://devcenter.heroku.com/articles/config-vars#local-setup

Failed to pull db from Heroku

Trying pull the database from Hekoku to local but failed.
heroku db:pull postgres://root:#localhost/db_name
Admittedly, I have no clue how should I construct the url. In the official site it was heroku db:push postgres://postgres:mypass#remotehost/mydb and in this article heroku db:pull postgres://root:#localhost/db_name was used. What the user name and password is for?
Anyway, the error message I got was:
Sequel::DatabaseConnectionError -> TypeError: wrong argument type Sequel::Postgres::Adapter (expected Struct)
Having followed the instructions by update the taps, sequel, and pg and here is my gem list:
rest-client (1.6.7)
sinatra (1.0)
taps(0.3.24)
sequel (3.37.0, 3.20.0)
pg (0.14.0)
This question is no longer relevant now as I have switched from the shared sqlite database to the 9.1 development pg database as been suggested here. Consequently, instead of using the simple db pull/push , I will use a more sophiscated pgbackup ,which was actually recommended by Heroku.

Resources