GeoPackage layer name adds 'main.' prefix

07-29-2021 12:44 AM
Labels (1)
New Contributor III

When I add a layer from a GeoPackage (which was created using arcpy), ArcGIS Pro gives the layer a prefix of 'main.' which doesn't look great but can also mess with my arcpy tools due to the invalid '.' character.

Is there a way of avoiding this prefix being added to the layer name?

0 Kudos
2 Replies
MVP Regular Contributor

I don't think so, this is a SQLite feature (Geopackages are based on SQLite).

SQLite supports the ability to "attach" other databases to a single database connection. The first database opened before you attach other databases, is called "main" (there is also "temp" for temporary stuff) by default: 

The database names ("main" or another "<YOUR_ATTACHED_DATABASE_NAME>") are essentially treated as database "schema" names by SQLite.

ArcGIS seems to inherit this structure (and I think for good reasons).

Since SQLite databases are here to stay in ArcGIS, especially now ESRI also introduced the SQLite based "Mobile Geodatabase" data format, I suggest you start adjusting your arcpy scripts to handle this, rather than trying to avoid this.

This will likely be the only viable option in the long run.



New Contributor III

Thanks Marco, yeah I'll look into accommodating this, either through the use of arcpy.ValidateTableName, or by renaming the layer when adding to the map.

0 Kudos