I'm trying to import a shapefile into a new PostGIS table, selecting specific fields from the input shapefile and adding a new date column to the output table. I'm using ogr2ogr with -sql option to select the fields from the shp that I would like to get imported and I'm using -dialect SQLite in order to be able to add current_date in my SQL request.
See below my ogr2ogr command :
ogr2ogr -f "PostgreSQL" -a_srs "EPSG:4326" PG:"host=<db_host> user=<db_user> password=<db_password> dbname=<db_name>" -nlt MULTIPOLYGON -nln <table_name> -sql "SELECT <shp_field1> AS <pg_field1>, <shp_field2> AS <pg_field2>, current_date AS date FROM <shapeFile>" `-dialect SQLite -overwrite <shapeFile>.shp
My problem is that if I don't use the -dialect option, the current_date is not understood in my SQL request, and if I use the -dialect option, I get the current_date working but the geometry is not imported in my output PostGIS table.
Am I missing something ?
SELECT
the geometry column - just addgeometry AS geom
to the command above.