I would like to use Windows task scheduler to automatically (monthly) create a new file geodatabase and then export feature classes from SDE into the new file geodatabase. Im using this code, however I get an exucute error that states that the geodatabase already exists.
# Name: CreateGDB.py
# Description: Create a file GDB
# Import system modules
import arcpy
import datetime
out_folder_path = "w:/GISDATA/Database_Backups"
nowstart = datetime.datetime.now()
YearMonthDay = nowstart.strftime("%Y_%m_%d")
out_name = "TEST_WSdata_" + YearMonthDay + ".gdb"
# Execute CreateFileGDB
arcpy.CreateFileGDB_management(out_folder_path, out_name)
arcpy.env.workspace = 'C:\Users\cbgibson\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\TEST_WSdata.sde'
# Local variables:
waterFC = ['WATERLINES', 'GRAVITY']
for fc in waterFC:
# Process: Feature Class to Geodatabase (multiple)
arcpy.FeatureClassToGeodatabase_conversion(fc, out_name)
Best Answer
I worked through the problem and found a solution. I also revised the code to copy ALL feature classes in the WATER dataset, instead of listing each one individually.