live access to postgis database to use in ExtJS, OpenLayers, etc

321 views
Skip to first unread message

Gery Herbozo

unread,
Oct 1, 2012, 5:48:05 PM10/1/12
to sqlal...@googlegroups.com
One general question, is it possible to create a live access to a
postgis database using sqlalchemy? the idea is to search records in
several tables. thanks in advance, regards

Michael Bayer

unread,
Oct 1, 2012, 5:57:50 PM10/1/12
to sqlal...@googlegroups.com
take a look at GeoAlchemy:

http://www.geoalchemy.org/

there's a new release upcoming for SQLAlchemy 0.8 that will be vastly improved.
> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>

Gery .

unread,
Oct 1, 2012, 6:38:43 PM10/1/12
to sqlal...@googlegroups.com

thanks but I want to use that live access to search at first through ExtJS/GeoExtJS/OpenLayers and through them there is only a url available (protocol HTTP), I also need to get the data as GeoJSON, so I think GeoAlchemy might not be the right solution, I think. If I'm wrong, please I'd love some points about it, thanks.





> Subject: Re: [sqlalchemy] live access to postgis database to use in ExtJS, OpenLayers, etc
> From: mik...@zzzcomputing.com
> Date: Mon, 1 Oct 2012 17:57:50 -0400
> To: sqlal...@googlegroups.com

Simon King

unread,
Oct 2, 2012, 9:43:21 AM10/2/12
to sqlal...@googlegroups.com
On Mon, Oct 1, 2012 at 11:38 PM, Gery . <game...@hotmail.com> wrote:
>
> thanks but I want to use that live access to search at first through
> ExtJS/GeoExtJS/OpenLayers and through them there is only a url available
> (protocol HTTP), I also need to get the data as GeoJSON, so I think
> GeoAlchemy might not be the right solution, I think. If I'm wrong, please
> I'd love some points about it, thanks.
>

It sounds like you are trying to do at least 6 quite complicated
things all at once, without really understanding any of them. This
will not be easy.

1. The client side of your application is presumably written in
Javascript and HTML, using javascript libraries such as ExtJS and
OpenLayers. You need to fully understand how these work.

2. The application will then make HTTP requests to a web server. You
need to understand at least the basics of HTTP.

3. The web server might be a single python script, or it could be
something running behind Apache. You need to understand your web
server.

4. The server side of your application might be using any of a number
of libraries to connect to the web server (such as
Django/Pyramid/Flask/cgi/mod_wsgi etc.). You need to understand
whatever mechanism your application is using to speak HTTP.

5. Your application can use SQLAlchemy and GeoAlchemy to retrieve data
from postgis into Python data structures. You will need to understand
postgis, SQLAlchemy, GeoAlchemy and Python.

6. Your application can then convert those Python data structures into
GeoJSON. You will need to understand GeoJSON.

The SQLAlchemy mailing list can help you with exactly one part of this
(step 5). SQLAlchemy (and GeoAlchemy) is perfectly capable of querying
multiple tables and retrieving results. But how you accept the HTTP
request, and how you pass the results back, are completely outside the
scope of this list and I'm afraid you are unlikely to find much help
here with it.

Sorry I can't be more help,

Simon

Gery .

unread,
Oct 2, 2012, 2:26:09 PM10/2/12
to sqlal...@googlegroups.com

thanks for the email, it seems that you know a lot about this stuff, it'd be great if you could share what you know so in that way we will learn from you, but as expected you won't do it, your "Sorry I can't be more help," is very clear as always. But hey anyway, I appreciate that you demostrate how you really are.




__________________________________________________________________________________________
Piensa en el medio ambiente - mantenlo en la pantalla. NO lo imprimas si NO es necesario.

Think green - keep it on the screen. Do NOT print if it is NOT necessary.
Denken Sie an die Umwelt - bewahren Sie es auf dem Bildschirm. Drucken Sie NICHT, wenn es NICHT notwendig ist.


> From: si...@simonking.org.uk
> Date: Tue, 2 Oct 2012 14:43:21 +0100
> Subject: Re: [sqlalchemy] live access to postgis database to use in ExtJS, OpenLayers, etc

Michael Bayer

unread,
Oct 2, 2012, 3:25:29 PM10/2/12
to sqlal...@googlegroups.com
On Oct 2, 2012, at 2:26 PM, Gery . wrote:


thanks for the email, it seems that you know a lot about this stuff, it'd be great if you could share what you know so in that way we will learn from you, but as expected you won't do it, your "Sorry I can't be more help," is very clear as always. But hey anyway, I appreciate that you demostrate how you really are.


If I'm reading this correctly, this is uncalled for - Simon is an incredibly helpful person, and on the SQLAlchemy list you'll get all the help you need in using SQLAlchemy and relational databases.   For general Python assistance you can try IRC channel #python, the comp.lang.python lists, and StackOverflow.

Simon King

unread,
Oct 3, 2012, 5:18:47 AM10/3/12
to sqlal...@googlegroups.com
On Tue, Oct 2, 2012 at 7:26 PM, Gery . <game...@hotmail.com> wrote:
>
> thanks for the email, it seems that you know a lot about this stuff, it'd be
> great if you could share what you know so in that way we will learn from
> you, but as expected you won't do it, your "Sorry I can't be more help," is
> very clear as always. But hey anyway, I appreciate that you demostrate how
> you really are.
>

I was just trying to demonstrate that what you are trying to do is
complicated, with a lot of interactions between different
technologies. You need to break it down into smaller tasks that you
can test, and get each piece working before starting on the next.

I recommend that you start by taking the example GeoJSON file from
http://www.geojson.org/geojson-spec.html#examples and saving that on
your web server. Change your javascript to load that file, and check
that you can actually see the data from the file in your application.
If you can't get this working you'll need to talk to someone who knows
about OpenLayers (I don't know anything about it)

Once you've done that, put a python script in the cgi-bin directory of
your web server that looks something like this:

------------------------------
#!/usr/bin/env python
# CGI scripts start by sending the HTTP headers. The only
# one you absolutely need is the Content-type header.
# I'm not sure if OpenLayers requires a specific content type
# so you may need to experiment here.
print "Content-type: application/json"

# In HTTP, a blank line separates the headers from the body
# of the response
print ""

# Anything else that you print forms the body of the response.
# In this case, we just want to send the example GeoJSON data.
print """
<include the example GeoJSON file here>
"""
------------------------------

Visit http://localhost/cgi-bin/yourscript.py in your web browser and
verify that you see the GeoJSON data. If that doesn't work, you'll
probably need to contact the Python mailing list.

Update your Javascript to point to that URL. You should still be able
to see the data within your application.

Once you've got all that working, you can start adding SQLAlchemy into
the python script. Let us know when you get there and we might be able
to help.

Simon

Gery .

unread,
Oct 3, 2012, 2:13:10 PM10/3/12
to sqlal...@googlegroups.com

thanks a lot for the answer, I didn't expect that, nice from you. I'll take a look at that and see what I keep doing, in fact I have set all the backend and client part, the only thing I need is to "leave the door open" to my pg tables, so I can (at first) search inside them and plot the features in OL. Through the postgis_geojson.php script and extjs I'm trying that because it allows what I need, it's just to find a way to pass the two variables I need and overwrite the default ext-comp104 of the xtype. But yes, this is beyond the scope of this forum. BTW my question (live access to postgis database) was related to what the MapFish guys did in the MapFish demo (great project btw, these guys are geniuses), they just use "an url" to do the search function, I know there is "bunch of things" behind (Pylons, etc), but I just wanted to know if it's possible to do it easier than that, perhaps with just SqlAlchemy, but I think a RESTful framework could work also.

Many thanks also Michael for your email, helpful as always.

Cheers,

Gery



__________________________________________________________________________________________
Piensa en el medio ambiente - mantenlo en la pantalla. NO lo imprimas si NO es necesario.

Think green - keep it on the screen. Do NOT print if it is NOT necessary.
Denken Sie an die Umwelt - bewahren Sie es auf dem Bildschirm. Drucken Sie NICHT, wenn es NICHT notwendig ist.


> From: si...@simonking.org.uk
> Date: Wed, 3 Oct 2012 10:18:47 +0100
> Subject: Re: [sqlalchemy] live access to postgis database to use in ExtJS, OpenLayers, etc
> To: sqlal...@googlegroups.com
>

Kent Tenney

unread,
Oct 3, 2012, 5:42:15 PM10/3/12
to sqlal...@googlegroups.com
"It sounds like you are trying to do at least 6 quite complicated
things all at once, without really understanding any of them. This
will not be easy."

Sigh. The story of my life in one sentence.
Reply all
Reply to author
Forward
0 new messages