[Python] queryByAttributes()

Andreas Albarello andreas.albarello at TERRITORIUMONLINE.COM
Wed Feb 14 03:51:49 PST 2007


Yves Jacolin wrote:
> I am trying to create a map using a python script. I got a problem with the 
> getByAttributes() method :
> myLayer.queryByAttributes(mapobject,"ville","ville=Paris",1)
> 
> The "Paris" string is viewed as a column name, and I can't change this, I 
> tried to used double and simple quote (" and '), tired to escape quote (\" 
> and \'), but all this failed !

Yves,

now, I don't know Python, but my guess is you're struggling with that 
query partially because of this bug:
http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1948

I would expect the following to work, but then I might be overlooking 
some Python-specific stuff:

myLayer.queryByAttributes(mapobject, None, "\"ville='Paris'\"", 1)

What's tricky in Mapserver 4.10.0, is that you need to wrap the entire 
query in quotes due to the bug I mentioned above.

Best regards,
-- 
--------------------------------------------------------------------
Andreas Albarello
Analysis & SW Development

Territorium Online srl/GmbH
Via Buozzi/Buozzistraße 12 - I 39100 Bolzano/Bozen
email: andreas.albarello at territoriumonline.com
web:   www.territoriumonline.com
--------------------------------------------------------------------



More information about the MapServer-users mailing list