Schema Lock in File Geodatabase when using Python to update shapefiles.

991
4
04-28-2017 04:53 PM
Anish_Adhikari
Occasional Contributor

We get data from external agencies which currently is a manual process. We are working on automating this using Python. The first script looks in the download folder for shapefiles and tables and updates our SQL Server Database which is the main data source which serves data to the public. This part is working well.

The second part is taking the same data and updating existing File Geodatabase which is used extensively by internal users and sometimes is even faster to work from than through SQL server connection. I have a portion of code that deletes the data from the existing shapefiles which basically leads to an empty table and the second portion appends data to that table.

My question is, do I have to worry about schema locks since all I am doing is erasing the table rows and appending data to the table and leaving the schema unchanged.  

Tags (1)
0 Kudos
4 Replies
JoshuaBixby
MVP Esteemed Contributor

I would think not, but the best answer will come from making some copies and testing it out.  Just to double check, when you say, "deletes the data from the existing shapefiles which basically leads to an empty table," you are purging the file or enterprise geodatabase table, right?  Or are the shape files empty?  Especially if the former, use Truncate to purge the table of records, it is what it is designed for.

Anish_Adhikari
Occasional Contributor

Thanks Joshua, For the Enterprise geodatabase, I am using truncate and for File GDB I am using delete_Features. I did some tests and its running well so far.

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Since you are going from an Enterprise SDE to a file gdb, have you thought about using one-way replication? 

I have a similar process where I basically replace my fgdb which is used for ArcGIS Server and user access. Because I do more than replace, I actually do all my work on a temp fgdb then replace my working fgdb.  I occasionally get file locks (not schema locks) and thinking the one-way replaca is the way to go.  Just throwing that out that in case you have considered it yet.

https://desktop.arcgis.com/en/arcmap/10.3/manage-data/geodatabases/replicas-and-geodatabases.htm

Anish_Adhikari
Occasional Contributor

Thanks Rebecca,

I did not think about file locks and replication. I will definitely look into replication.

0 Kudos