Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
    
What you are describing is correct, you will want to create the script that is part of your tool. But you may consider based on what you are trying to do instead just talking to your database through a native driver. In a couple places in my apps I actually use the MSSQL classes to talk direct to my SQL2008 DB, versus relying on those tables to be registered with SDE. –  D.E.Wright Jun 1 '11 at 15:36
    
I was thinking about this, but we have to go through the flex api, so have to go through a geoprocessing service –  Hairy Jun 1 '11 at 19:08
    
It's going to be this database connection string, I think. How do I create the link to the database from the server? –  Hairy Jun 2 '11 at 7:28

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
Thanks - I am loading up the script of the kind of thing I want to do in an edit. It doesn't work, but am unsure as to why... –  Hairy Jun 2 '11 at 6:30
    
Have you tried running the toolbox locally? Just via either ArcCatalog or ArcMap? So you are sure the references all work right? You need to make sure you have relative paths setup for your connections and the toolbox, when you move it to the server you can see these break and get little or no information returned to you. –  D.E.Wright Jun 2 '11 at 17:02

OK, after much oo'ing and from'ing, I can see what the issue was here.

First, make sure when you add the script, you check properties (right click on the script), and in the first tab (Genrral), make sure 'store relative path names (instead of absolute paths)' is checked.

Make sure under the second tab (Source) that the file you are using is accessible, and that 'Run Python script in process' is checked.

Finally, ensure you have a connection file in the same directory (of the script/toolbox/mxd) and that it is properly referenced.

Seems to work now...

edit

I should add the back end is all linux, including the ArcSDE instance. I have lock issues now, but we'll address them.

share|improve this answer
    
Very good; glad to see you got it. –  D.E.Wright Jun 2 '11 at 17:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.