Friday 5 July 2019

qgis - Why can't I edit polygons once they have been saved to MySQL?


I have a simple table with an id field and a polygon field in mySql. Using QGIS I can add new polygons and give them an id. Before saving them I can also edit them.


But once a polygon has been saved it cannot be edited any more: every time I move it, it simply moves back to the original position when I save the edits. Added points disappear when saving.


The same happens with a point field in a different table.


What could be the problem?




Answer



I've noticed that ogr2ogr, when it imports and creates MySQL tables, does not flag the OGR_FID field as Primary Key (PK) and/or Auto Increment (AI)---I forget which it is. But as you found out, it seems QGIS has a similar behavior.


With ogr2ogr, I usually experience this as MySQL Workbench complaining that it cannot edit the data, and I fix this by opening the table to ALTER it, and making sure the OGR_FID field is flagged for both PK and AI.


It sounds like applying this solution against QGIS/MySQL also did the trick for you. Good deal---I'm happy it was that simple. 8)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...