Question

Primary key error when writing Geopackage

  • 31 August 2021
  • 5 replies
  • 51 views

Badge +14
  • Contributor
  • 120 replies

I am trying to write a bunch of shape files to a geopackage but am getting a strange error.

 

'OGCGEOPACKAGE writer: sqlite3_exec(CREATE TABLE "table_name" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'

 

There seems to be a problem when the writer constructs the primary keys for the database, but I have no idea how to address this.

 

There is no id attribute in the source data, I actually tried adding one and the writer handled this by changing the name of the primary key to id_0. Still got the same error though.

 

I am using fme_feature_type to set the table names and schemas.


5 replies

Badge +6

Hi @aron​, Are you using a Writer with dynamic settings your shape files? Would you be able to share your reader and writer parameters?

Badge +20

Use AttributeExposer to expose the id attribute followed by AttributeRemover to remove it.

Shape files have a baked in id attribute and you have to get rid of it to write to another database file format.

Badge +14

Use AttributeExposer to expose the id attribute followed by AttributeRemover to remove it.

Shape files have a baked in id attribute and you have to get rid of it to write to another database file format.

Thanks!

 

I tried exposing (and deleting) 'multi_reader_full_id' and 'multi_reader_id' but that did not work. What is the name of the ID attribute?

Badge +20

Thanks!

 

I tried exposing (and deleting) 'multi_reader_full_id' and 'multi_reader_id' but that did not work. What is the name of the ID attribute?

Try "id" lowercase, simple. Don't look for it, just type it in manually.

You have to brute force it

Badge +1

Using the recent fme 2022.2 doesn't allow to update or delete an existing geopackage when the original input(s)' primary keys were exposed and deleted.

 

Depending on my input feature, the primarykey to update is alternatively named 'id' or 'fid'.

 

The error message is:

OGCGEOPACKAGE writer: OGCGEOPACKAGE writer: For feature type 'table1', existing primary key is named 'id' but no attribute was found on schema with that name. Updates and deletes must use the existing primary key

 

Alternatively, I could consider renaming both potential primary key names to a single one. How could this be done?

Reply