I know QGIS comes with its field calculator, which is not bad. It also comes with ftools which permits several operations on geometry and attributes. But we often need more control and I haven't seen any convenient tool in QGIS to perform such operations (where you can select fields you need for example or perform arithmetical operations on them while doing a spatial query).

Basically, I'd like to know if a SQL console (a kind of Mapinfo mapbasic window) is on the roadmap of QGIS and if not, if it would be hard to code it as plugin. If it exists yet, please let me know, i've missed it! ;-)

  • 4
    This doesn't really seem like a good question for this site. It would be better put to QGIS devs on one of their mailing lists. A better question might ask how to do a specific thing or get a certain result with QGIS. Questions about planned features will become moot and pointless or even wrong in time. – Sean Mar 15 '11 at 19:30
  • 1
    FastSQL is awesome! Especially that you can replace the layer you are looking at immediately. This adds extraordinary power to QGIS connected to PostGRES. However, I have found one problem, and that is the use of the spatial operators. I can perform basic SQL queries in FastSQL, but none of the spatial queries for. For example, this query works just find in the DB Manager plugin: select * from wetlands,watersheds where st_intersects(wetlands.geom,watersheds.geom) but, when I try it in FastSQL, it says its not a valid layer and cannot be added to the map. I'm thinking that there is something pr – user16112 Mar 13 '13 at 13:06
  • I spent a lot of time to find the way to do that in QGIS 2.0. Most of the answers here and on google are outdated. @Simo : Can you check HeyOverThere's answer as the best answer? It will be easier for next readers to find the fresh correct answer. – Nicolas Boisteault Dec 13 '13 at 9:03
  • This is done (with an additional comment) – simo Dec 13 '13 at 9:31
  • Can you tell us why the answer doesn't satisfy you completely? – Nicolas Boisteault Dec 13 '13 at 10:11

The new DB Manager plugin is now a standard part of QGIS from 1.8 forward. It has autocomplete, syntax highlighting, and you can add layers created from a spatial query to your map.

In 1.9 (the development version for 2.0) DB Manager adds import / export functions that are pretty handy.

  • I'm not satisfied with this answer because I was looking for a built-in tool that works whatever the data format is, but as @Nicolas-Boisteault said, accepting this answer may put other people into the right direction. I hope, so! – simo Dec 13 '13 at 13:49

RT Sql Layer plugin can do what you want (but it's not a console).

enter image description here

You can use python console too: 'PostGIS ’select’ statement as vector layer in QGIS'

  • Thanks underdark. I also know that plugin but it relies on Postgis layer use. Actually I would like to have a tool which is not format input dependent (as orbisgis propose, see agemen post) – simo Mar 16 '11 at 8:49
  • 3
    I see. I haven't heard of any such plans. Maybe a plugin that uses spatialite in the background could be an approach. This could be a topic for Google Summer of Code. – underdark Mar 16 '11 at 10:38
  • Should I add myself a request on qgis.org/wiki/Google_Summer_of_Code_2011? I'm not sure I cant create an account on gqis wiki page. – simo Mar 16 '11 at 12:56
  • You can ask on the user mailing list to get a wiki account. (We had spam problems.) At the same time, you can ask other user/dev opinions on the topic. – underdark Mar 16 '11 at 13:00
  • 1
    @Nathan > Nice, you are following that post. I should really submit the idea on qgis dev list (except if you did it already?). Using a standard SQL to query any type of data is just fantastic (see orbisgis). – simo May 17 '11 at 13:14

there is a new plugin available: Fast SQL Layer.
It opens an docked sql console with code highlighting.

  • 1
    very cool, a good start! Note: depends on Pygments (so for OSGeo4W users, there are few manual steps to build/install this) – Mike T May 24 '11 at 23:34
  • 1
    Yes, for now the solution is to copy pygments to the site-packages folder of osgeo4w instalations. It worked for me. Soon I will release and updated version to solve that. – Pablo May 24 '11 at 23:54
  • 1
    I downloaded and extracted Pygments-1.4.tar.gz, then in an OSGeo4W shell within the Pygments-1.4 directory, type python setup.py build then python setup.py install – Mike T May 25 '11 at 1:01

is SQL Query Editor (for PostGIS) what your looking for?



I don't know such a tool in QGIS. Another open-source GIS software offers such capabilities, however, that is named OrbisGIS : http://www.orbisgis.org

Unfortnuately, as one is written in C++ and the other is in Java, it would be certainly difficult to link them... :-(

  • Actually, i'm also an orbisgis user (i'm a former STEU student) ;-) -switching from one to other ... and I think your SQL console so efficient that I'd like to have the same on qgis (I mentionned mapbasic in my question because it's more known!). Orbisgis allows a full control through the SQL console but it can take time to perform some basic operations. At the opposite, Qgis is designed to perform easily some basic operations but make it harder for full control operations. – simo Mar 16 '11 at 9:10
  • I understand what you mean... Fortunately, the last version of OrbisGIS add auto-completion in the SQL console. And we are working to add the ability to perform basic operations outside of the SQL console. – Agemen Mar 16 '11 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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