Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Qgis 1.8.0, and spatialite 2.3 in a Windows Vista machine.

I have a database in Spatialite, and I have created a view from one of its tables. When I open it in QGIS, using add Spatialite Layer (and enabling non-spatial tables), the attribute table shows ERROR in all of its lines and rows, but the number of rows and attributes seems correct.

I have tried both with spatial and non-spatial views withou sucess and opening tables (spatial or not) works well.

My table and view is something like this:

pkuid integer primary key autoincrement,
"UnidadeID" text,
"Tipo" text,
"Descricao" text,
"Data" text,
"Responsavel" text)

CREATE VIEW AccoesPoltest AS
SELECT c.* FROM Accoes as c

I have already read all info provided in this related question: Can Qgis Read Spatialite Views?

I also found a very old bug ticket from QGIS, with the exact same issue, but it was closed as invalid:

This is one of my first approaches with Qgis + Spatialite, so probably something is missing. Any idea? Thanks

Alexandre Neto

share|improve this question
I have now realized that QGis 1.8.0-3 uses Spatialite 3.0.1 and not 2.3, could this be a problem? – Alexandre Neto Aug 31 '12 at 11:45
hi , I am an beginner with spatalite, nevertheless I would suggest to try loading into the free spatialitegui ( and see what happens there. spatialitegui is from the developer of spatialite and needs no install-routine – Kurt Aug 31 '12 at 15:47
@kurt, I guess we are both beginners... I have no problems with the views in SpatialiteGUI, actually I have created them with it. – Alexandre Neto Aug 31 '12 at 21:26
@AlexandreNeto Was this ever resolved? I am having the same issue with SQLite/spatiaLite 3.7.9/3.0.1 and QGIS 1.8.0 compiled against spatiaLite 3.0.1. – Scro Oct 8 '12 at 20:51
It worked following the SpatiaLite Cookbook. I did not have a ROWID, and its a must. – Alexandre Neto Oct 8 '12 at 23:03
up vote 3 down vote accepted

I got my answer by following the SpatiaLite Cookbook. I didn't have a ROWID in my view, and it seams to be must in order to open in QGIS.

Therefore, for my specific case, All I needed to do is assign "pkuid" key as ROWID, just like this:

pkuid integer primary key autoincrement,
"UnidadeID" text,
"Tipo" text,
"Descricao" text,
"Data" text,
"Responsavel" text)

CREATE VIEW AccoesPoltest as
SELECT c.pkuid as ROWID, c.* FROM Accoes as c
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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