Select to view content in your preferred language

Register Postgres table with geodatabase using Python

1510
3
09-22-2016 01:02 PM
JeremyKnaggs
Deactivated User

How do I use Python and arcpy (or sql commands) to register a new postgres database table with geodatabase? I've programmatically created a new table which, among other things, has an st_geometery column but before I can view this table in ArcDesktop I always need manually "register with a geodatabase". I believe this has to do with the need to have an "objectid".. I've tried creating a column called "objectid" and making sure it contains a not null integer but I still have to register the table...Surely there must be a way to bypass this manual step and just use python to create the table and do the "registration". How can this be accomplished? 

0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

I don't use this in any of my workflows, but is this the tool you use in arctoolbox? or is this a catalog process only

Register with Geodatabase—Help | ArcGIS for Desktop 

If it is this, the code sample might help

Then there was this thing Create Unregistered Table—Help | ArcGIS for Desktop 

and this Add Incrementing ID Field—Help | ArcGIS for Desktop 

hopefully you can cobble something together

JeremyKnaggs
Deactivated User

Thanks Dan. Using the "RegisterWithGeodatabase_management" seemed to do the trick. I'm not really using any tools in arctool box or arc catalog. I was just looking for a way to create and write to databases that various GIS tools can read from. ArcDesktop seemed to refuse to map any geometry in the database unless i first register the table as a geo-database. Not sure why the extra step is necessary, but I'll just go with it.

0 Kudos
DanPatterson_Retired
MVP Emeritus

jJeremy, good... The functionality of the tool can be accessed through python, should you decide to continue on that route... just see the code snippets at the bottom of every tool in arctoolbox.

0 Kudos