+ Reply to Thread
Results 1 to 6 of 6

Thread: issues updating data source via arcpy.mapping

  1. #1
    Roberto Figueroa
    Join Date
    Apr 2010
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default issues updating data source via arcpy.mapping

    Hi,
    I am running the python script listed at the bottom of this message to update the data source of many layers included in one of my .mxd's.
    Although the script loops though all layers in the map, the data source is only updated in the first 37 layers of more than 350 in the map.
    All layers I am trying to point to are stored in SDE in a single SQL Server 2005 database.
    After running the Pyhton script in ArcMap, I intermittently get an error message for my SDE connection saying that "Maximum number of connections to instance exceeded". Perhaps the "lyr.replaceDataSource " method tries to connect multiple times to SDE and runs out of connections.
    Any assistance would be greatly appreciated.
    Best regards
    Roberto


    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    mxd = arcpy.mapping.MapDocument("CURRENT")
    for lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.isFeatureLayer:
    wrkspcpath = r"C:\Documents and Settings\rfiguero\Application Data\ESRI\Desktop10.0\ArcCatalog\cmtni_emili_sde_SYSTEST.sde"
    old_dataname = lyr.datasetName
    new_dataname = old_dataname + '_1'
    lyr.replaceDataSource (wrkspcpath, "SDE_WORKSPACE", new_dataname)
    print wrkspcpath, new_dataname
    Last edited by rfiguero; 02-16-2011 at 11:34 AM.

  2. #2
    Jeffrey Barrette

    Join Date
    Oct 2009
    Posts
    712
    Points
    201
    Answers Provided
    64


    0

    Default Re: issues updating data source via arcpy.mapping

    We are aware of this issue and are working on a fix. It won't be available for SP2.

    In order to support some workflows we did not recycle SDE connections with each lyr iteration so lyr.replaceDataSources is creating a new SDE connection with each iteration. The cache is cleared when the script stops running or sometimes when you delete the variable references.

    Some workarounds are to:

    1) Try deleting the lyr variable at the end of each loop. This does not always work.
    2) Increase the number of available SDE connections on your server.
    3) Decrease the number of layers that are updated within a single loop/script. One example may be that your script iterates through 25 layers at a time. You could have one master script that calls each subscript.

    Jeff

  3. #3
    Ruth Emerick
    Join Date
    Feb 2011
    Posts
    36
    Points
    1
    Answers Provided
    0


    0

    Default Re: issues updating data source via arcpy.mapping

    Jeff, is there any chance setting up direct connections to the SDE would help with this? I've run into the same problem as Roberto.

  4. #4
    Jeffrey Barrette

    Join Date
    Oct 2009
    Posts
    712
    Points
    201
    Answers Provided
    64


    0

    Default Re: issues updating data source via arcpy.mapping

    We can reproduce this issue an will hopefully be able to address it in the next service pack.

    If you want to check its status, it is: NIM067157

    Thanks,
    Jeff

  5. #5
    Jeffrey Barrette

    Join Date
    Oct 2009
    Posts
    712
    Points
    201
    Answers Provided
    64


    0

    Default Re: issues updating data source via arcpy.mapping

    This issue has been fixed and will be available with SP3.

    Thanks,
    Jeff

  6. #6
    Ruth Emerick
    Join Date
    Feb 2011
    Posts
    36
    Points
    1
    Answers Provided
    0


    0

    Default Re: issues updating data source via arcpy.mapping

    Quote Originally Posted by jbarrette View Post
    This issue has been fixed and will be available with SP3.

    Thanks,
    Jeff
    Woot! Thanks!

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts