Last active
July 17, 2020 04:04
-
-
Save razzius/ccbf0430e2c05a68393132d29c7bf616 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment