How to import a file geodatabase to SQL Server using a Python Script? Are there any limitations? Which modules can I use to create a python script? Is pyodbc module the most appropriate one? Anyone has already any examples to show? thks, M.
Manuela:
Have you considered arcpy and the Feature Class to Feature Class command?
Here is a code sample:
I did Joe. But I am looking to import the full file geodatabase in one go rather than exporting each feature class..
There are some options mentioned here (although it is the other way around it will work for your case too): Copy a list of feature classes from Enterprise to Geodatabase
Manuela,
You can simply use the same code mentioned in the help for Feature Class To Geodatabase—Help | ArcGIS Desktop. This should easily create all you feature classes in your target database with the same names. In case you have some non-spatial tables that also need to be moved in your target database you can use Table To Geodatabase—Help | ArcGIS Desktop
Just keep in mind that you will have to add the an environment setting for the if you are using any. Refer What are configuration keywords?—ArcGIS Help | ArcGIS Desktop
I hope this helps!
~Shan
If this is a one time deal, and you don't need it to be a Python script, you can do a copy-paste (using OS commands like control-c, control-v) into a Sde geodatabase. The geodatabase would have to exist first, and you my want to copy datasets one at a time, not that it will not work all at once, but you have a bit more control knowing what has completed.
if for a class or will be repeated, I agree that feature classe to featureclass as mentioned above would be you best option.
HI Rebecca, it is not a one time deal. It should be automated a recorrer every month.
Manuela,
The sample script that is provided in Feature Class To Geodatabase—Help | ArcGIS Desktop and Table To Geodatabase—Help | ArcGIS Desktop
along with the CONFIG_KEYWORD can be invoked on demand using Task Scheduler which can be set to execute on a desired date in the month.
Refer Scheduling a Python script to run at prescribed times—Help | ArcGIS Desktop
I hope this helps!
~Shan
Hey Shan, how can I add/ update config keyword while copying the fgdb to sql server? I can do it in GUI where it allows me the option to change it from DEFAULT to GEOMETRY. How can I do it using Arcpy?