Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def build_connection_file():
- """This function handles everything involved in building a connection
- file to the manhole feature class in sewer"""
- directory = r"C:TempConnectionFiles"
- if not os.path.isdir(directory):
- os.path.makedirs(directory)
- feature_dataset = r"ThisIsReal"
- feature_class = r"ThisIsReal"
- sde = r"Database ConnectionsReal.sde"
- versions = [version.name for version in arcpy.da.ListVersions(manhole_sde)
- if (getpass.getuser() in version.name)]
- print versions[-1]
- connection_name = "ThisIsReal.sde"
- if not os.path.isfile(os.path.join(directory, connection_name)):
- arcpy.CreateDatabaseConnection_management(
- out_folder_path = directory,
- out_name = connection_name,
- database_platform = "real_platform",
- instance = "real_instance",
- account_authentication = "OPERATING_SYSTEM_AUTH",
- username = "",
- password = "",
- save_user_pass = "DO_NOT_SAVE_USERNAME",
- database = "real_database",
- version_type = "TRANSACTIONAL",
- version = versions[-1])
- connection_feature_class_full = os.path.join(
- directory, connection_name, feature_dataset,
- feature_class)
- print connection_feature_class_full
- #this was required last time I did this.
- table_view = arcpy.MakeTableView_management(
- in_table = connection_feature_class_full,
- out_view = r"connection_table", where_clause = "",
- workspace ="", field_info = "")
- arcpy.ChangeVersion_management(
- in_features = table_view, version_type = "TRANSACTIONAL",
- version_name = versions[-1], date = '')
- print("changed version")
- return connection_feature_class_full
- connection_feature_class = build_connection_file()
- edit = arcpy.da.Editor(manhole_connection_feature_class_full)
- edit.startEditing(True, False)
- edit.startOperation()
Add Comment
Please, Sign In to add comment