Skip to main content
Solved

SpatiaLite questions


jorge_rosales
Contributor
Forum|alt.badge.img+8

I need generate a SpatiaLite database that stores a 1:n relationship. The 1 side is a spatial table and the n side is a non spatial table. Firstly I create a template (template.sqlite from template.sql).

If I use only the SpatiaLite writer I get an error with the non spatial table (test1.fmw). Maybe I misunderstand the meaning of wkb_none. If I use a SpatialLite writer for the spatial table and a Sqlite for the non spatial table, everything runs ok but it seems that FME ignores an existing constraint in the template database (test2.fmw).Workspaces: Source data: https://goo.gl/5FfJBs

Best answer by pallegama

Hi @j4,

Looking at the SLQITE3 writer parameters, I noticed that 'Template File' parameter has not been set properly. Could you please set this parameter and try again.

Regards,

Priyantha

View original
Did this help you find an answer to your question?

4 replies

pallegama
Contributor
Forum|alt.badge.img+8
  • Contributor
  • Best Answer
  • October 11, 2017

Hi @j4,

Looking at the SLQITE3 writer parameters, I noticed that 'Template File' parameter has not been set properly. Could you please set this parameter and try again.

Regards,

Priyantha


jorge_rosales
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 11, 2017
pallegama wrote:

Hi @j4,

Looking at the SLQITE3 writer parameters, I noticed that 'Template File' parameter has not been set properly. Could you please set this parameter and try again.

Regards,

Priyantha

Both writers point to the same destination file so if you use two templates files (one per writer) the second will overwrite the database (and data) created by the first one.

 

 


pallegama
Contributor
Forum|alt.badge.img+8
  • Contributor
  • October 13, 2017
jorge_rosales wrote:
Both writers point to the same destination file so if you use two templates files (one per writer) the second will overwrite the database (and data) created by the first one.

 

 

Hi @j4,

 

 

I found the exact cause for this issue. Unfortunately, I don't have required ArcGIS license to test the workspace with your original input. However, this should resolve the issue.

 

To identify the issue, I have created sample spatial data (ffs) file and attribute data (csv).

 

 

The issue is you have to enable the Foreign key constraint in Sqlite in run time passing the command 'PRAGMA foreign_keys = ON'. ( Please find more information in this regard in the link https://sqlite.org/foreignkeys.html).

 

 

This can be achieved in FME by passing this command to 'SQL To Run Before Writer' parameter in the Sqlite Writer as depicted in the image below.

 

To test the workspace, please run it with provided CSV file which contains a FK value violating the constraint. This should fail the worksapce.

 

Then remove the last record of CSV file (which violate the FK constraint) and run the process again. Then it should run successfully.

 

 

spatialite.zip

 

 


jorge_rosales
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 16, 2017

Thank you @pallegama, it works. Maybe the "PRAGMA foreign_keys = on" should be the SpatiaLite Writer default behaviour. I think it would be clearer.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings