I can emit plain values in SQLite3:

$ echo 'select 1;' | sqlite3

However, SpatiaLite always emits a greeting:

$ echo 'select asgeojson(st_point(1,2));' | spatialite
SpatiaLite version ..: 5.0.0    Supported Extensions:
        - 'VirtualShape'        [direct Shapefile access]
        - 'VirtualDbf'          [direct DBF access]
        - 'VirtualText'         [direct CSV/TXT access]
        - 'VirtualGeoJSON'              [direct GeoJSON access]
        - 'VirtualXL'           [direct XLS access]
        - 'VirtualNetwork'      [Dijkstra shortest path - obsolete]
        - 'RTree'               [Spatial Index - R*Tree]
        - 'MbrCache'            [Spatial Index - MBR cache]
        - 'VirtualFDO'          [FDO-OGR interoperability]
        - 'VirtualBBox'         [BoundingBox tables]
        - 'VirtualSpatialIndex' [R*Tree metahandler]
        - 'VirtualElementary'   [ElemGeoms metahandler]
        - 'VirtualRouting'      [Dijkstra shortest path - advanced]
        - 'VirtualKNN'  [K-Nearest Neighbors metahandler]
        - 'VirtualGPKG' [OGC GeoPackage interoperability]
        - 'SpatiaLite'          [Spatial SQL - OGC]
        - 'VirtualXPath'        [XML Path Language - XPath]
PROJ version ........: Rel. 7.2.0, November 1st, 2020
GEOS version ........: 3.8.1-CAPI-1.13.3
RTTOPO version ......: 1.1.0
TARGET CPU ..........: x86_64-linux-gnu
the SPATIAL_REF_SYS table already contains some row(s)

Both the greeting and my desired GeoJSON are going to stdout:

$ echo 'select asgeojson(st_point(1,2));' | spatialite >/dev/null
the SPATIAL_REF_SYS table already contains some row(s)

How can I run spatialite command-line tool and get it to emit only the stuff that I need (in this example, the GeoJSON)?

1 Answer 1


Have a look at the help screen.

spatialite -help
Usage: spatialite [OPTIONS] FILENAME [SQL]
FILENAME is the name of an SQLite database. A new database is created
if the file does not previously exist.
OPTIONS include:
   -bail                stop after hitting an error
   -batch               force batch I/O
   -column              set output mode to 'column'
   -cmd command         run "command" before reading stdin
   -csv                 set output mode to 'csv'
   -echo                print commands before execution
   -init filename       read/process named file
   -[no]header          turn headers on or off
   -help                show this message
   -html                set output mode to HTML
   -interactive         force interactive I/O
   -line                set output mode to 'line'
   -list                set output mode to 'list'
   -silent              suppress the welcome message
   -nullvalue 'text'    set text string for NULL values
   -separator 'x'       set output field separator (|)
   -stats               print memory stats before each finalize
   -version             show SQLite version
   -vfs NAME            use NAME as the default VFS

Option -silent looks promising.

It almost works on Windows like this:

echo select asgeojson(st_point(1,2)); |spatialite -silent
        - 'VirtualXPath'        [XML Path Language - XPath]

Please file a bug report into the SpatiaLite Fossil repository about the VirtualXPath that cannot be silenced.

  • Thanks! Re. bug report -- I built spatialite from source (spatialite-tools b204bdfa8232383b4c36837443f4f5c5dc1b248f, libspatialite c2c4ea9179b6cda7e7aa6fd5e8a29c9108911762) and it doesn't emit the VirtualXPath message any more. Dec 14, 2020 at 10:51
  • Yes, I noticed that it has been fixed by gaia-gis.it/fossil/libspatialite/info/760ef1affb822806 and some older ticket.
    – user30184
    Dec 14, 2020 at 10:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.