AnsweredAssumed Answered

remote connection question

Question asked by zlm0922 on Oct 15, 2019
Latest reply on Oct 16, 2019 by zlm0922

I want to connect a remote sever via python code ,my code is :

arcpy.env.workspace = r"Database Connections\Connection to 10.246.146.120.sde"
wk = r"Database Connections\Connection to 10.246.146.120.sde"

def list_feature_batch1(pathsde):

    env.workspace = pathsde
    # print arcpy.env.workspace
    datasets = arcpy.ListDatasets()
    datasets = [''] + datasets if datasets is not None else []
    #print datasets
    wklst = []
    for ds in datasets:
        # print ds
        # env.workspace = env.workspace + os.sep + ds
        wk = env.workspace + os.sep + ds
        # print env.workspace
        wklst.append(wk)
    return wklst

# print arcpy.env.workspace
# database = 'Database Connections\\Connection to 10.246.146.120.sde'
# versions = arcpy.ListVersions(database)
for dataset in list_feature_batch1(wk):
print dataset
......
list_feature_batch1 is a function,it works well.

why doesnot the code work,but when I add code that arcpy.env.workspace = r"Database Connections\Connection to 127.0.0.1.sde
the code can run correctly.

Outcomes