@ Echo off set sdeserver = 192.168.0.16set geosdeservice = 5151 set geousername = user_mingkofset geouserpassword = upwd_mingkofrem name used to separate set geofeatureclassnames = gis_t1, gis_t2echo ----------------------------- ECHO is exporting space data echo ----------------------------- echo 'echo 'Python sde2gbd. PY % sdeserver % geosdeservice % geousername % geouserpassword % geofeatureclassnames % echo 'echo ----------- ------------------ The echo space data has been exported! Echo ------------------------------- echo. & pause
_ Author _ = 'mingkof' # Coding = cp936 # import arcpy moduleimport osimport arcpyfrom arcpy import envimport timeenv. overwriteoutput = true # SDE host address sdeserver = arcpy. getparameterastext (0) # SDE service port number sdeservice = arcpy. getparameterastext (1) # SDE username sdeusername = arcpy. getparameterastext (2) # SDE User Password sdepassword = arcpy. getparameterastext (3) # Name of the layer to be copied featureclass_list = arcpy. getparameterastext (4) featureclass_list = Str. split (featureclass_list, ",") Try: yymmdd = time. strftime ('% Y % m % d', time. localtime (time. time () hhmmss = time. strftime ('% H % m % s', time. localtime (time. time () # year, month, and day folder out_gdb_folder_path = OS. path. abspath ('. ') + "\" + yymmdd sdefilepath = ipvsdefilename = hhmmss # hour/Second file out_gdb_name = hhmmss # GDB file path out_gdb_path = hour +' \ '+ out_gdb_name + '. GDB '# create a directory if not OS. path. exists (out_gdb_folder_path): OS. mkdir (out_gdb_folder_path) print 'create output directory end' # create the gdb file arcpy. createfilegdb_management (out_gdb_folder_path, out_gdb_name, "current") print 'create GDB file '#. SDE file path sdefilepath_sde = sdefilepath + "\" + sdefilename + ". SDE "If OS. path. isfile (sdefilepath_sde): OS. remove (sdefilepath_sde) print 'delete existing SDE file' # create an SDE file arcpy. createarcsdeconnectionfile_management (sdefilepath, sdefilename, sdeserver, sdeservice, "", "database_auth", sdeusername, sdepassword, "save_username", "SDE. default "," save_version ") print 'create SDE file' print" SDE export GDB start "# loop output featureclass_listcount = Len (featureclass_list) indexi = 1 for tempfeature in featureclass_list: print 'processing '+ STR (indexi) + "/" + STR (featureclass_listcount) + "_" + tempfeature indexi + = 1 tempsde = sdefilepath_sde + "\" + tempfeature tempgbd = out_gdb_path + "\" + tempfeature arcpy. copyfeatures_management (tempsde, tempgbd, "", "0", "0", "0") # Delete the SDE file if OS. path. isfile (sdefilepath_sde): OS. remove (sdefilepath_sde) print 'delete SDE file' print "SDE export GDB end" failed t valueerror: Print valueerror