Using stored procedures

18 views
Skip to first unread message

mark

unread,
Jul 20, 2008, 11:07:33 PM7/20/08
to web2py Web Framework
Is there a better way to use a stored procedure than executesql?
Executesql works fine for my purposes, but I wanted to see if there
was a better way to go about using them. I couldn't find anything on
the web.

The stored procedures are part of PostGIS for PostgreSQL
(distance_sphere and GeometryFromText):

def messages_within_radius():
sql_string = 'SELECT * from message where
distance_sphere(GeometryFromText(\'POINT(\' || longitude || \' \' ||
latitude || \')\', 2), GeometryFromText(\'POINT(-122.415686
37.799724)\', 2)) > 105;'
records = db.executesql(sql_string)
return dict(records=records)

Is anyone doing anything else with PostGIS and web2py? Also couldn't
find much on that.

Thanks,

Mark

Massimo Di Pierro

unread,
Jul 22, 2008, 8:04:29 AM7/22/08
to web...@googlegroups.com
I do not think there is a better way right now but you can propose
one. ;-)

Massimo

Massimo Di Pierro

unread,
Jul 22, 2008, 8:33:38 AM7/22/08
to web...@googlegroups.com
On a second thought....

cond="distance_sphere(GeometryFromText(\'POINT(\' || longitude || \'

\' ||latitude || \')\', 2), GeometryFromText(\'POINT
(-122.41568637.799724)\', 2)) > 105"

records=db(cond).select(db.message.ALL)

Massimo


On Jul 20, 2008, at 10:07 PM, mark wrote:

mark

unread,
Jul 22, 2008, 2:24:47 PM7/22/08
to web2py Web Framework
Nice. Much Cleaner.

I am looking into developing something to interface with PostGIS from
web2py, possibly using Shapely (http://trac.gispython.org/projects/PCL/
wiki/Shapely). I'll post it if I ever get there.

Thanks,

Mark
Reply all
Reply to author
Forward
0 new messages