Re: best.Re: [Qgis-developer] Spatialite ’select’ statement as vector layer in QGIS

Ivan Mincik ivan.mincik at gmail.com
Sun Dec 12 17:28:54 EST 2010


On Sun, Dec 12, 2010 at 10:36 PM, Ricardo Filipe Soares Garcia da
<ricardo.garcia.silva at gmail.com> wrote:
> Hi Paolo, all
>
> Uploaded a new version (v0.3) of the 'Custom DB query' plugin.
>
> I've added it to the 'database' menu. Also, it is now possible to save
> the result of the SQL query as a new table in its corresponding
> database.
>
> So, to summarize, you can run SQL queries over postgis or spatialite
> databases and get the results:
>
> - in a table view
> - as a 'real time' layer displayed over the map canvas
> - as a new table, that gets saved to the database and is immediately
> loaded to the map canvas
>
> It is still pretty raw, so I'm keeping it in the 'experimental'
> section, but it seems to work OK with my small test datasets.


Hi Ricardo,
nice plugin. For me the best feature is that it is possible to load
and visualize every PostGIS query, not only queries based on real
tables (this is what I miss in perfect 'RT_' plugins).

But after upgrading to v. 3.0 I get following traceback when trying to
load every query in PostGIS (for example: SELECT * from schema.table).

 Traceback (most recent call last):
 File "/home/ivo/.qgis/python/plugins/customdbquery/CustomDBQueryDialog.py",
line 173, in parse_SQL_text
   self.execute_query(selectQuery)
 File "/home/ivo/.qgis/python/plugins/customdbquery/CustomDBQueryDialog.py",
line 196, in execute_query
   connectionSettings, self.geomField, self.idField)
 File "/home/ivo/.qgis/python/plugins/customdbquery/CustomDBQuery.py",
line 70, in load_to_canvas
   idField, dbSchema)
 File "/home/ivo/.qgis/python/plugins/customdbquery/CustomDBQuery.py",
line 97, in prepare_postgis_uri
   uri.setDataSource(dbSchema, "%s" % query, geomField, '', idField)
TypeError: QgsDataSourceURI.setDataSource(): argument 1 has unexpected
type 'NoneType'

Python version:
2.6.6 (r266:84292, Oct  9 2010, 11:55:20)
[GCC 4.4.5


Ivan


More information about the Qgis-developer mailing list