I have a layer in QGIS called "Limite administrative". I have connected a PostgreSQL database. I use "Export layer to PostgreSQL" and the export works.
My problem is that the name of the layer is transformed to "Limiteadministrative" (the space is dropped down).
Is it a way to forced the table/column names to put the string in double quotes? As it is the case in some other apps?
-
Have you tried enclosing the table name in double quotes, table to export to = "your name"?Bera– Bera2024年01月15日 09:38:27 +00:00Commented Jan 15, 2024 at 9:38
-
1No, it doesn't work... What is strange, is if I take the layer and drop it directly in the postgreSQL database in the browser, the name of the table keeps the space. But not if I use the process "Export to PostgreSQL".katagena– katagena2024年01月15日 09:58:11 +00:00Commented Jan 15, 2024 at 9:58
-
1If everything else fails, you can try renaming the table in PostgresJGH– JGH2024年01月15日 13:40:31 +00:00Commented Jan 15, 2024 at 13:40
1 Answer 1
I suppose that by disabling laundering from the tool "GDAL-Vector miscellaneous-Export to PostgreSQL" the space in the name would be preserved. I do not understand why you would like to keep the space but that is not my headache.
If that does not work then you can use ogr2ogr for making the export.
ogr2ogr -f PostgreSQL PG:"host=localhost port=5432 dbname=mydb user=user password=pw" -lco launder=no -nln "A Layer NamE wiTH headACHE" test.json
Test the result:
ogrinfo PG:"host=localhost port=5432 dbname=mydb user=user password=pw"
...
88: A Layer NamE wiTH headACHE (Polygon)
-
No, it doesn't work! It preserve the space in the attribute table, but not in the name of the layer.katagena– katagena2024年01月15日 09:31:17 +00:00Commented Jan 15, 2024 at 9:31
-
"I do not understand why you would like to keep the space but that is not my headache". Because I have symbology that use the name of the layers, and I don't want to redo it...katagena– katagena2024年01月15日 09:33:29 +00:00Commented Jan 15, 2024 at 9:33
-
Mmmh, it seems to work, BUT the name is not anymore in Uppercase (first letter).katagena– katagena2024年01月15日 10:07:21 +00:00Commented Jan 15, 2024 at 10:07
-
1I edited my answer and added an ogr2ogr command that keeps all the oddities that you can wish.user30184– user301842024年01月15日 13:13:13 +00:00Commented Jan 15, 2024 at 13:13