Select to view content in your preferred language

Python script to copy UN data from one SDE to another SDE

429
3
Jump to solution
03-12-2026 02:26 AM
Ashok
by
Regular Contributor

Hello community,

I have an Electric UN data in my SDE database. I would like to export/copy this UN data to another SDE database on regular intervals like daily once. So what I need is, I need to create a Python script to do this copy/export. And once the script is ready, then I can make task schedular to run this script daily once. 

Is there any script readily available to do this task? 

Thanks in advance.

Ashok

 

 

0 Kudos
1 Solution

Accepted Solutions
RobertKrisher
Esri Regular Contributor

There are typically three approaches to this problem, and each approach has different benefits, depending on what you're trying to achieve. I would only choose one of the other two options (below) if you were looking for a way to ONLY copy the utility network data and wanted to leave the rest of the objects in the database behind.

  1. If you're looking to create a complete copy of your entire database, including your utility network, then restoring a database backup to a create a new database is usually the fastest option. Unfortunately you can't just backup one schema and restore it, you must backup and restore the entire geodatabase because you need the schemas that contain SDE and the utility network, along with any other schemas referenced by SDE.
  2. Export/Import asset package, highlighted by @PierreloupDucroix, gives you the most control, and themost information if something goes wrong. The downside to this approach is that you must enable your network topology and update your subnetworks afterwards, which can be time consuming.
  3. Copy/Paste or Export/Import XML Workspace document are another way of doing this without needing to download any tools from solutions. This approach has the benefit of preserving the state of your utility network (topology, subnetworks, etc).

This is discussed on the utility network dataset administration page of the online help.

View solution in original post

0 Kudos
3 Replies
PierreloupDucroix
MVP Regular Contributor

Hello,

You will need to write your own Python script. We used the same method to export SDE UN data to a mobile geodatabase.

In short, this is done in two steps:
UtilityNetworkToAssetPackage, then AssetPackageToFileGeodatabase.

In your case, you will also need to clean the schema/dataset if you want to overwrite it. Furthermore, the second step does not work for writing to an SDE geodatabase; you will need to perform additional steps:
StageUtilityNetwork then AssetPackageToUtilityNetwork.

The benefit of this process is that it will highlight any errors that might exist in your Utility Network.

However, you could also perform a backup/restore of the entire schema to another database.

CEO of MAGIS
RobertKrisher
Esri Regular Contributor

There are typically three approaches to this problem, and each approach has different benefits, depending on what you're trying to achieve. I would only choose one of the other two options (below) if you were looking for a way to ONLY copy the utility network data and wanted to leave the rest of the objects in the database behind.

  1. If you're looking to create a complete copy of your entire database, including your utility network, then restoring a database backup to a create a new database is usually the fastest option. Unfortunately you can't just backup one schema and restore it, you must backup and restore the entire geodatabase because you need the schemas that contain SDE and the utility network, along with any other schemas referenced by SDE.
  2. Export/Import asset package, highlighted by @PierreloupDucroix, gives you the most control, and themost information if something goes wrong. The downside to this approach is that you must enable your network topology and update your subnetworks afterwards, which can be time consuming.
  3. Copy/Paste or Export/Import XML Workspace document are another way of doing this without needing to download any tools from solutions. This approach has the benefit of preserving the state of your utility network (topology, subnetworks, etc).

This is discussed on the utility network dataset administration page of the online help.

0 Kudos
PierreloupDucroix
MVP Regular Contributor

For your information, you can use the POST_PROCESS option with AssetPackageToFileGeodatabase or AssetPackageToUtilityNetwork. This will automatically enable the network topology and update all subnets.

However, the administration documentation for the utility-network dataset indicates that, when importing XML workspace document, the topology will be disabled and the subnets marked as modified. Therefore, you will need to enable the topology and update the subnets somehow if you want to script the copy.

Only copy-pasting seems to eliminate this need.

 

CEO of MAGIS
0 Kudos