[gdal-dev] Add timestamp field with value to table during ogr2ogr operation
Even Rouault
even.rouault at spatialys.com
Sun Oct 29 04:02:52 PDT 2017
On dimanche 29 octobre 2017 09:58:06 CET Bo Victor Thomsen wrote:
> To the list -
>
> I'm converting shapefiles to postgres tables using ogr2ogr. As usual
> with ogr2ogr, it works very well.
>
> Now I want to automatically add an extra column "created" with the
> current timestamp during the ogr2ogr operation.
>
> Something like this:
>
> ogr2ogr ..... -sql "SELECT *, CURRENT_TIMESTAMP AS created FROM
> point_data" ....
>
> Shapefile name is "point_data.shp" and CURRENT_TIMESTAMP is a SQL92
> standard function
OGR SQL is only a partial implementation of SQL92 :
http://gdal.org/ogr_sql.html
>
> However, It doesn't work. Is there some way, I can add this timestamp
> value to the resulting table using a built-in function in ogr2ogr?
You may use the SQL SQLite dialect by adding -dialect SQLite
( http://gdal.org/ogr_sql_sqlite.html )
to your ogr2ogr command line, and that will do what you expect
Or almost, as I see that the column is recognized as a String column with values like
'2017-10-29 10:26:43'. So you may need to do some SQL transformation on the PG database
to properly type it.
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171029/9432c4e1/attachment.html>
More information about the gdal-dev
mailing list