0

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?

asked Jan 15, 2024 at 8:28
3
  • Have you tried enclosing the table name in double quotes, table to export to = "your name"? Commented Jan 15, 2024 at 9:38
  • 1
    No, 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". Commented Jan 15, 2024 at 9:58
  • 1
    If everything else fails, you can try renaming the table in Postgres Commented Jan 15, 2024 at 13:40

1 Answer 1

2

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.

enter image description here

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)
answered Jan 15, 2024 at 9:23
4
  • No, it doesn't work! It preserve the space in the attribute table, but not in the name of the layer. Commented 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... Commented Jan 15, 2024 at 9:33
  • Mmmh, it seems to work, BUT the name is not anymore in Uppercase (first letter). Commented Jan 15, 2024 at 10:07
  • 1
    I edited my answer and added an ogr2ogr command that keeps all the oddities that you can wish. Commented Jan 15, 2024 at 13:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.