Skip to content

Instantly share code, notes, and snippets.

@Kameshwaran
Created February 7, 2019 06:39
Show Gist options
  • Select an option

  • Save Kameshwaran/14b058b36cd967b4ad065b29fd091070 to your computer and use it in GitHub Desktop.

Select an option

Save Kameshwaran/14b058b36cd967b4ad065b29fd091070 to your computer and use it in GitHub Desktop.

Revisions

  1. Kameshwaran created this gist Feb 7, 2019.
    10 changes: 10 additions & 0 deletions heroku-database-url-to-config.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # Sample DATABASE_URL = dbms://username:password@hostname:port/dbname

    DB_PROTOCOL=$(echo $DATABASE_URL | cut -d':' -f1)
    DB_DETAILS=$(echo $DATABASE_URL | cut -d'/' -f3)
    DB_NAME=$(echo $DATABASE_URL | cut -d'/' -f4)
    HOST_NAME=$(echo $DB_DETAILS | cut -d'@' -f2 | cut -d':' -f1)
    PORT=$(echo $DB_DETAILS | cut -d'@' -f2 | cut -d':' -f2)
    USER_NAME=$(echo $DB_DETAILS | cut -d'@' -f1 | cut -d':' -f1)
    PASSWORD=$(echo $DB_DETAILS | cut -d'@' -f1 | cut -d':' -f2)