Skip to content

Instantly share code, notes, and snippets.

@cosmin
Created March 30, 2009 09:52
Show Gist options
  • Save cosmin/87720 to your computer and use it in GitHub Desktop.
Save cosmin/87720 to your computer and use it in GitHub Desktop.
# parse a DSN
import re
regex = re.compile(r':(mysql|postgres)://(?:([\w]+)(?::([\w]+))?@)?([\w.-]+)(?::([\d]{1,5}))?')
def parsedsn(string):
return regex.match(string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment