Defining SDE connection in Python

559
2
01-04-2011 12:54 PM
PeterTung
New Contributor
Hi all,

I'm having a bit of a hard time finding a good reference on how to approach this...

The task assigned is for me to write a python script to run on Linux.  I was able to write the script on the Windows development environment without any issue... however I realized that I have no clue how to define an SDE connection on the Linux system.

I looked up some new and old forum threads but still I can't seem to find my way around, there are some references to use the sde file (create them on Windows with ArcCatalog then copy to Linux) which I haven't tried, but the preferred way is still to just have the user be able to define the connection somehow. 

Our Linux system is not using an ArcServer environment, rather just the ArcEngine 9.3.1 license is being used.  If there's any reference to a document on how to do that, or some forum posts that has some examples, I'd really appreciate the help.

For clarification, I just need to execute SynchronizeChanges_management(SDE1, replicaname, SDE2).  There really isn't much to do other than figuring out how to get the python scripts to run properly (already got that done) and to define SDE connections as parameters somehow...

Thanks,
Peter
Tags (2)
0 Kudos
2 Replies
PeterTung
New Contributor
A bit of an update.  So I tried to just do a very simple test to make sure SDE connection works with the use of the connection.sde files.  My SDE servers are configured such that one of them is running on a Windows server connected to a SQLServer database, and the other is running on a Linux server connecting to an Oracle database.

import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.SetProduct("ArcEditor")

try:
    gp.workspace = r"/home/sde/ptest/script/SDE_SQLServer.sde"
    # gp.workspace = r"/home/sde/ptest/script/SDE_Oracle.sde"
    fcs = gp.ListDatasets()
    print "Listing datasets:\n"
    for fc in fcs:
        print fc
except:
    errMsg = gp.GetMessage(0)
    errMsg += gp.GetMessage(2)
    print "Error:" + str(errMsg)


This code snippet works when I run it on a Windows system (with different path), but when I try to run it on the Linux box, I either don't get any dataset back (blank line after "Listing datasets:", or I get the message that says "Aborted".  Apparently that's not coming from the except block either since I don't see the "Error:" text.

Any help is greatly appreciated.
0 Kudos
PhanindraDulam
New Contributor
Hi,

I have same reqirement. If any one got Idea.

please reply to us.


Thank you,
0 Kudos