Select to view content in your preferred language

Conecting to SDE and ODBC

842
1
08-31-2012 10:06 AM
MikeBly
Regular Contributor
Here is a script that I am running to attempt to copy FD from an SDE to a FGDB on another server. I have ran this script with tests FGDB setup on a single server and it works. Now when I attempt to run the script, nothing happens, no errors, nothing. I get an exit code of 0, when I hit run it returns the 0 code in probably a half a second. So nothing has ran.

Do I need to setup a new path in the ODBC in order for this code to be able to find the connection to the SDE? And if so, how do I set this up properly?

Here is the code:

# Import system modules
import arcpy
from arcpy import env
import os, sys, traceback

# Set environment settings
arcpy.env.workspace = "Database Connections\\COL_LCT_SDE.sde"
dir
##arcpy.env.overwriteOutput = True

# Set local variables
outpath = r"G:\\PythonTest.gdb"
##outpath = r"I:\\ROBOTEST.gdb"
##pre = 'COL_LCT_SDE.'

# Copy feature datasets to new FGDB
try:
    fdList = arcpy.ListDatasets("*","Feature")
    copy1 = 'ManagedData'
    copy2 = 'PublicWorks'
    copy3 = 'Annotation'
    copy4 = 'TCA'
    copy5 = 'ReferenceData'

    for fd in fdList:
        pastefd = outpath + os.sep + str(fd)

        if fd == copy1:
            arcpy.Copy_management(fd, pastefd)

        if fd == copy2:
            arcpy.Copy_management(fd, pastefd)

        if fd == copy3:
            arcpy.Copy_management(fd, pastefd)

        if fd == copy4:
            arcpy.Copy_management(fd, pastefd)

        if fd == copy5:
            arcpy.Copy_management(fd, pastefd)

except:
    arcpy.AddError(arcpy.GetMessages(2))
                  
   
del fdList

Thanks,

Mike
Tags (2)
0 Kudos
1 Reply
emelinerenz1
Deactivated User

You shouldn't need to set up an ODBC connection to get this to work. There may just be a syntax error in your code. I already see a few syntax error, so you might want to review your code again.

How are you executing the script? In IDLE?

0 Kudos