GeoPackage layer name adds 'main.' prefix

216
2
07-29-2021 12:44 AM
Labels (1)
ToyotaT18
New Contributor II

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
MarcoBoeringa
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:

https://www.sqlite.org/lang_attach.html 

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.

 

 

ToyotaT18
New Contributor II

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