Create Replica using arcpy

2636
10
10-14-2016 05:06 AM
AsteriosTselepis1
New Contributor II

I am creating a replica using python/arcpy and the tables which are being replicated are empty, only the schema is replicated. Is it possible to replicate also all the data in the tables using arcpy?

10 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Asterios,

With the CreateReplica_management function, the default for the expand_feature_classes_and_tables parameter for feature classes is to replicate all features; the default for tables is to replicate the schema only.  You will want to set this parameter to ALL_ROWS to replicate the table rows.

KipoKipo
New Contributor III

I tried ALL_ROWS and the replicated table still remained empty. Is there any update on this issue?

I guess replicating table with records should be DEFAULT because that is normally what replication does. From the project automation point of view it is much easier if this can be done by Arcpy.

Thanks!

KP

0 Kudos
AlexanderBrown5
Occasional Contributor II

Kipo,

Can you post your exact code snippet?

~Alex

0 Kudos
KipoKipo
New Contributor III

The GP tool ran through and the snippet is as follows, but the table is still empty. Only with the Distributed Geodatabase toolbar did the table replica run through with complete records, based on my experience.

arcpy.CreateReplica_management(in_data="c:/Work/sqlcon/sqlwork.sde/sqlwork.DBO.ACIT", in_type="ONE_WAY_REPLICA", out_geodatabase="c:/Work/sqlcon/ser2work.sde", out_name="TabRep", access_type="FULL", initial_data_sender="PARENT_DATA_SENDER", expand_feature_classes_and_tables="ALL_ROWS", reuse_schema="DO_NOT_REUSE", get_related_data="GET_RELATED", geometry_features="", archiving="DO_NOT_USE_ARCHIVING")

Thanks!

0 Kudos
AlexanderBrown5
Occasional Contributor II

Kipo,

Instead of using the C path, try to utilize your direct database connection to your sqlwork.sde

For example my original SQL geodatabase is Enterprise_SDE

Replicated database is Replicated_SDE

Feature Class is "python_precision"

Here is the path to the origin feature class using the database connection path:

Database Connections\Enterprise_SDE.sde\Enterprise.SDE.python_precision‍‍‍‍‍‍‍

I was able to get the code below to work just fine utilizing the actual database connection paths.

import arcpy
arcpy.CreateReplica_management(in_data="Database Connections\Enterprise_SDE.sde\Enterprise.SDE.python_precision", in_type="ONE_WAY_REPLICA", out_geodatabase="Database Connections\Replicated_SDE.sde", out_name="TabRep", access_type="FULL", initial_data_sender="PARENT_DATA_SENDER", expand_feature_classes_and_tables="ALL_ROWS", reuse_schema="DO_NOT_REUSE", get_related_data="GET_RELATED", geometry_features="", archiving="DO_NOT_USE_ARCHIVING")‍‍‍‍

Try that and let me know if that works!

~Alex

KipoKipo
New Contributor III

Hi Alex,

I still have no luck with this featureTable replication. The replicated table has only schema.

import arcpy
arcpy.CreateReplica_management(in_data="Database Connections/sqlwork.sde/sqlwork.DBO.ACIT", in_type="ONE_WAY_REPLICA", out_geodatabase="Database Connections/ser2work.sde", out_name="TabRep", access_type="FULL", initial_data_sender="PARENT_DATA_SENDER", expand_feature_classes_and_tables="ALL_ROWS", reuse_schema="DO_NOT_REUSE", get_related_data="GET_RELATED", geometry_features="", archiving="DO_NOT_USE_ARCHIVING")

Thanks!

KP 

0 Kudos
AlexanderBrown5
Occasional Contributor II

Hi Kipo,

I am sorry that is still not working for you.  What version of ArcGIS are you utilizing for:

1. Desktop

2. SDE

Also, what version of SQL Server?

~Alex

0 Kudos
KipoKipo
New Contributor III

Hi Alex,

I'm using 10.5 and Sql Express 2014. Comparing your snippet with mine I

suspect that the express version might be the issue?

KP

0 Kudos
DarylHochhalter
Occasional Contributor II

I am currently having the very same issue using model builder and ArcGIS 10.4 advanced.

0 Kudos