I'm tried to importing an Esri shapefile into GRASS GIS using both v.in.ogr and v.in.import however methods fail with the following error message:

WARNING: Table <roadsSriLanka> linked to vector map <roadsSriLanka> does
         not exist
Creating attribute table for layer <edges>...
DBMI-SQLite driver error:
Error in sqlite3_prepare():
near "from": syntax error

DBMI-SQLite driver error:
Error in sqlite3_prepare():
near "from": syntax error

ERROR: Unable to create table: 'create table roadsSriLanka (cat integer,
       access varchar ( 80 ), bridge varchar ( 80 ), from varchar ( 80 ),
       highway varchar ( 80 ), junction varchar ( 80 ), key varchar ( 80 ),
       landuse varchar ( 80 ), lanes varchar ( 80 ), length varchar ( 80 ),
       maxspeed varchar ( 80 ), name varchar ( 161 ), oneway varchar ( 80
       ), osmid varchar ( 231 ), ref varchar ( 80 ), service varchar ( 80
       ), to varchar ( 80 ), tunnel varchar ( 80 ), width varchar ( 80 ))'

This shapefile was downloaded using the OSMnx Python package. I used another file which I downloaded using the same which imported without an issue

  • 2
    Your shapefile seems to have an attribute "from" that is a reserved keyword for SQL. GRASS should generate a bit different SQL with double quotation marks create table (... "from" varchar (80),. That may be considered as a bug but it requires more research. As a workaround try to rename the attribute into for example x_from.
    – user30184
    Aug 7, 2019 at 11:29
  • Thank you @user30184. This solved the problem!
    – Nandula
    Aug 8, 2019 at 9:36

1 Answer 1


By looking at the error message the failure occurs when GRASS (or GDAL/OGR) is trying to create a SQLite table. The SQL create table statement is included in the message, and the error is pointed to happen somewhere near to "from".

The case can be simplified into

CREATE TABLE foo (from);

The command will fail and throw the error message near "from": syntax error because from is a reserved keyword in SQL and it can't be used as an attribute name with that syntax. See the list of 140 currently reserved keywords in SQLite.

The create table statement would work if the reserved keyword was enclosed between double quotation marks for making it into quoted identifier

CREATE TABLE foo ("from");

Because you can't change the behavior of GRASS or GDAL without changing the program code the best you can do is to use a workaround and rename the offending shapefile attribute "from" into some not reserved name, like "x_from".

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.