Can't use PSQL with a Heroku shared database - heroku

I'm developing an application and hosting it on Heroku. For now, I want to use the free shared database solution.
My problem is that I can't access the database.
$ heroku pg:psql
! Cannot ingress to a shared database
I've read elsewhere that I can't connect to shared databases via psql.
I can't seem to find any information on that on Heroku's Dev Center, so this leaves me with the question - how can I edit or change or do anything with my database?

If you're happy to use a beta addon then there is the Heroku Shared PostgreSQL 9.1 addon (https://addons.heroku.com/heroku-shared-postgresql) which will permit you to ingress to your database.
However, any changes to your database are usually best done with scripted migrations (in the Ruby on Rails world) rather than connecting to your database to make changes.
If you're more familiar with mySQL then there are a number of mySQL addons which permit direct access also with normal mySQL tools.

Related

Laravel sqlite database locked

I am using the Azure web app with PHP 7.3 stack. In my project, we have the feature to sync from mobile to web and for that, we are using the SQLite file. And for other modules, we have a MySQL database.
The mobile app sends the SQLite file and we stored it in the directory. But we try to make a query to the SQLite with PDO then it throws the error that the database is locked.
I tried many solutions from the other's answer but not get success.
This has to do with permissions of the underlying storage mount.
One option you could try is mounting an Azure File share and persisting the database there, see https://learn.microsoft.com/answers/answers/320889/view.html. The best option however is to utilize a cloud database such as Postgres or MySQL for Azure.

Ruby & SQLite & Heroku & PostgreSQL

I've a simple Sinatra application which I've developed using SQLite. The database is a simple two-column table: an ID and a string entry.
I would like to deploy this app to Heroku. What's the least painful way to convert an SQLite database to PostgreSQL, understanding that PostgreSQL is required to deploy to Heroku.
For simple use cases heroku db:push will push your local sqlite database into your Heroku Postgres database.
It's worth considering then switching to using Postgres locally and then use heroku db:pull to bring the database back from Heroku to your new local postgres instance.
I'll caveat to say that whilst heroku db:pull works for SIMPLE databases once you start using more complex Postgres datatypes then you need to use something like heroku pg:transger which is Postgres > Postgres only.
Use the taps gem, as shown in this Railscast.
First you'll want to install Postgres on your local machine so you can make changes and easily deploy to heroku. Second you'll want to migrate from SQLite to Postgres. I just did the migration for my own Rails app following Heroku's instructions and it took less 5 minutes. Seems simple enough.
The instructions to migrate are here (even has instructions on installing Postgres locally). Then you can follow the Heroku getting started guide for the rest.

Navicat access for Heroku database

I'm having troubling accessing a free Heroku database (Dev plan) through Navicat.
When I connect I can see a long list of databases, much like here http://twitter.com/bazscott/status/290780256221147136, but I cannot find my particular database in the list, neither can I connect to any of the others.
Is this because I'm using a free database plan, and only paid plans allow Navicat access?
PS. I have no problem accessing my database through heroku pg:psql.

Some help regarding Postgres on Heroku

i have just started working on an application in PHP. I have configured the Postgres add on in my application on Heroku. But i am still not sure how to start working on the DATABASE. what i mean is that there is a thing called DATACLIP on the POSTGRES DB window on Heroku and when i try to create a table there, it gives me some weird errors.
But no matter what query i write there, it always gives me some error. So, i am not sure whether i can create the Tables and insert my data from DATACLIP or not. and If not, from where can i do this?
Dataclips are only useful for read-only queries. Think gist for SQL and data.
To create data on your database, you can:
Use database migrations that run within the heroku platform itself
Connect to your database using the provided credentials from anywhere (you must use SSL). To get credentials, either run heroku pg:credentials <DATABASE_COLOR> --app <YOUR_APP>, or go to your database in http://postgres.heroku.com. You should be able to use pg_admin or any other postgres front end to connect and create tables.
You can connect directly using the heroku toolbelt (and assuming you have a proper psql installation in your dev box) with heroku pg:psql --app <YOUR_APP>. From there just use SQL to create your data (CREATE TABLE, etc)

How do i look at postgres data in heroku while using a shared database?

I cannot access the db directly because it is shared. Any recommendations on how I could get pretty intricate data tables out?
You probably want to use the dev plan, this will allow you to ingress and runs on the same version as the production instances - https://devcenter.heroku.com/articles/heroku-postgres-dev-plan

Resources