Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to create an action that select many rows from PostGIS table to show many lines in QGIS. How can i select many rows from table with python to add these rows in a layer?

Thank you

share|improve this question
2  
what do you mean registers? –  Nathan W Apr 22 '13 at 11:36
    
registers = rows –  user1573901 Apr 22 '13 at 13:45
    
do you just want to add a postgis layer using python? can you add more clarity? –  vinayan May 23 '13 at 2:51
add comment

1 Answer

assigning an Action Type of Python you can add multiple column field values (separated with a space), as follows:

u'[% "col_name1" %]' + " " + u'[% "col_name2" %]' 

if you need to add data from numerous rows and create a new table view in QGIS, you should think about creating a plugin

share|improve this answer
    
Can I make a action python with that query?:SELECT * FROM pathways WHERE gid IN(SELECT mpp_path_id FROM meetingpoints_paths WHERE mpp_meeting_id = [% "gid" %]) –  user1573901 Apr 22 '13 at 14:15
    
It looks like you are using PostGIS based on the "gid" primary key. However, if you were using sqlite/spatialite you could perform SQL using: import sqlite3; con = sqlite3.connect("mydatabase.sqlite"); cur = con.cursor(); cur.execute("SELECT...the rest of my SQL statement ") –  user12711 Apr 22 '13 at 14:43
    
the python sqlite3 module will not handle spatialite geometries. alternately, would want to import the pyspatialite module. and use pyspatialite.dbapi2.connect("mySpatialite_DB.sqlite") to establish an object for your cursor to perform SQL on –  user12711 Apr 22 '13 at 15:14
add comment

Your Answer

 
discard

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.