Load data to standalone SQL Server using Python

1542
1
04-18-2017 11:06 AM
Anish_Adhikari
Occasional Contributor

We are using standalone SQL server(2008) to store Geographic and Table data which is consumed by our GIS web application and internal GIS users. We get data from external sources which we have scripted to download using shell scripts daily and is working fairly well. The next step was then to push the downloaded data to File Geodatabase which is working well using Python. The final step is to copy the same data to SQL Server. I have been able to add logic to the Python code that checks if the SQL database table has feature classes  and tables with same name as downloaded data and if that is true,  uses "arcpy.TruncateTable_management" to delete all the table rows resulting in empty tables. Now, I want to load data to the empty tables which I can do manually right now by right clicking on the table name and using "Simple Data Loader Tool". The problem I am having is I have not been able to find a tool inside ArcMap that lets me automate this part. The "Append Tool" worked in the File Geodatabase but does not work with SQL Server as it is technically not a geodatabase. Is using PyOdbc my only option? 

I am using ArcMap 10.4.1, SQL Server 2008 Standalone(Not SDE), File Geodatabase 

0 Kudos
1 Reply
AlexanderBrown5
Occasional Contributor II

Anish,

Take a look at insert cursors:

InsertCursor—Help | ArcGIS Desktop 

~Alex