Friday, 2 December 2016

arcgis 10.0 - Creating a GP script to update a table in SDE


I need to create a geoprocessing script to update a table on an SDE server, with some text input from the user.



I thougth what I needed to do was create a toolbox with a python script associated with it, but it appears more than that; is there a resource online to help me do this, or have you any suggestions?


I thought I'd simply create a python script with the text to input along with 2 other parameters and inside the script, I'd create the link to the database, and simply use the input to update the table. This, however, isn't proving the right way to do it, so please, any ideas?


Thanks in advance.


Resolved



Answer



For sure you want to look at The Script/Model repository at ESRI, you will find more than one example there that you can take and expand on. You are right, you will want to create a toolbox to publish, in that a script that accepts the values you want, and then you will need to have in your script the connection to the SDE database with the appropriate connection and insert/update/delete the appropriate connection. There is some good python examples here that you can dig through.


You really need to make sure you are doing try/catch type logic around you methods; its very easy to have a exception throw in your tool and have the python engine run-away.


You don't need to do everything in python! If you create a good process in Modelbuilder and can publish the model properly; then go with that; python just really has more flexibility for really doing powerful stuff. For a task wher you want to select a record; then update fields and close the connection. You should be pretty good to go.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...