Alternative to replication for copying features in SDE?

334
3
04-05-2013 01:17 PM
JeremyRead
New Contributor II
We need to replicate data from SDE 10.0 to SDE 9.2, which is not possible using replicas due to all the changes between versions 9.2 and 10.  I know of at least one case where someone is doing this very thing using Python, but I unfortunately do not have access to their script and have no idea how they're doing it.

Basically, they are copying a featureclass from SDE 10 to SDE 9.2, while SDE 9.2 is running and also while that featureclass is being accessed in the 9.2 SDE.  I have tried a few options to do this and always run into locks on the 9.2 featureclass since it is currently in use by other users/applications.  We pretty much need to do what a replica does:  synchronize changes (adds/deletes/modifications) in the featureclass between the two databases without having to stop the database or block access to the featureclass.

How would you go about accomplishing this in Python?  I have searched through the geoprocessing documentation and simply cannot figure out how to do this.  All of my searches lead back to replication, but again, creating a replica that will move data from SDE 10 to SDE 9.2 is not possible.

Any and all ideas would be most appreciated!
Tags (2)
0 Kudos
3 Replies
JeremyRead
New Contributor II
Ok, well I think I've figured out what to do, but I don't know how yet:

1.  To search for differences between the feature classes and then find what features have been added, modified or deleted:  SearchCursor

2.  To update features in the target feature class that have been updated in the source feature class:  UpdateCursor

3.  To delete features in the target feature class that have been deleted from the source feature class:  UpdateCursor

4.  To add features to the target feature class that have been deleted from the source feature class:  InsertCursor


Now I have to figure out how to actually compare the feature classes, store the differences somewhere, then read from the differences and update the target feature class accordingly.  Since I am basically just making edits, I don't have to worry about whether or not the feature class is being accessed (read-only, so it will only be viewed while I am making the edits; it won't be edited by anyone else).
0 Kudos
JeremyRead
New Contributor II
So, I've basically gotten this working (not to the finished script yet, though).

I'm using search cursors to build dictionaries of the feature classes, only providing an ID field and a modified date field (which is used to key off of for Updates).

I compare the dictionaries and anything that is in the source featureclass, but not the target, is added to a list of "adds".  Anything that is in the target feature class, but not in the source, is added to a list of "deletes".  Anything that is in both feature classes but has a different "modified date" is added to a list of "updates".

I am then using insert/update cursors to iterate through the rows of the feature classes, and making edits where appropriate until they have identical data.

I'll post the finalized script later once it is ready.
0 Kudos
SendhilKolandaivel
New Contributor
Jeremy,

Your approach sounds good.

Are there any other data/logic tied to this feature class that also need to be brought down?  i.e, are there any relationship class, feature linked annos associated with this feature class?  If yes, then you need to account for those as well.

Sendhil
0 Kudos