def splitDSN(dsn):
    """Do our best to extract host and database specification from DSN."""
    if dsn[:2] == '\\\\':
        i = dsn.find('\\', 2)
        host = dsn[2:i]
        db = dsn[i:]
    else:
        colon = dsn.find(':')
        if colon in (-1, 1):
            host = None
            db = dsn
        else:
            host, db = dsn.split(':', 1)
    return host, db
