Skip to content

Instantly share code, notes, and snippets.

@razzius
Created July 17, 2020 04:04
Show Gist options
  • Save razzius/587f11e5986837151300c979970b9d23 to your computer and use it in GitHub Desktop.
Save razzius/587f11e5986837151300c979970b9d23 to your computer and use it in GitHub Desktop.
from urllib.parse import urlparse
database_url = input()
parsed = urlparse(database_url)
parts = {
'port': parsed.port,
'dbname': parsed.path[1:],
'host': parsed.hostname,
'user': parsed.username,
'password': parsed.password
}
connection_options = ' '.join(
f'{name}={value}'
for name, value in parts.items()
)
print(connection_options)
@razzius
Copy link
Author

razzius commented Jul 17, 2020

pg_dump (heroku config:get DATABASE_URL -a hms-weave | python3 dburl_to_connection.py) -t hospital_affiliation_option -a | heroku psql -a hms-weave-staging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment