Skip to content

set5think/heroku-db-url-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Heroku Plugin for convenient format conversion of database urls

Extends heroku pg command-line to parse database urls to other file formats. By default, it will parse the value of DATABASE_URL from the output of heroku config.

This extension aids in the situation where you need to convert your database url to another format. For example, if you want to create an alias to a psql connection in your .bash_login, it gets annoying to copy and paste it and then move things around, or if you want to add this database url to your .pgpass file, which is a different format than psql.

Installation

$ heroku plugins:install https://github.com/set5think/heroku-db-url-parser.git

Usage

$ heroku pg:parse_db_url HEROKU_POSTGRESQL_NAVY_URL --format=pgpass

$ heroku pg:parse_db_url HEROKU_POSTGRESQL_NA --format=psql #matches the closest config env to 'HEROKU_POSTGRESQL_NA', which in this case would be HEROKU_POSTGRESQL_NAVY_URL

$ heroku pg:parse_db_url # parses DATABASE_URL and formats to psql, by default

$ heroku pg:parse_db_url --format alias --aliasname pgfoo  # outputs an alias declaration for psql suitable for bash_profile or bashrc

$ heroku pg:parse_db_url --format alias --aliasname pgfoo --aliascommand pg_dump  # outputs an alias declaration for pg_dump suitable for bash_profile or bashrc

$ heroku pg:parse_db_url --format psql,pgpass  # outputs both formats fo DATABASE_URL

Supported Databases

Currently, Postgres is the only supported database, but more are coming very soon.

Supported Formats

  • pgpass (specific to Postgres)
  • psql (specific to Postgres)
  • pg_dump (specific to Postgres)
  • pg_restore (specific to Postgres)
  • rails_yaml (renders host, database, username, password and port in yaml format to plug in to database.yml)
  • alias (psql alias for bash_profile. use the aliasname option to set the name in the output)

Todo

Support databases/data-stores other than Postgres. Support other string formats other than psql and pgpass

License

This plugin is released under the MIT license. See the file LICENSE.

Copyright

Copyright © 2013 Hassan Shahid & Lukas Eklund

About

Parses a database URL to various formats

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages