Use BAT to call py to back up SDE data to GDB

Source: Internet
Author: User
@ 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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.