Re: [sqlalchemy] Could someone please give an example of this paragraph in the Documentation -- Using the session?
I also appreciate such example! Hope simple terminology with a simple example can replace the sometimes complicated documentation. Sent from my i386 On Mar 15, 2014, at 16:31, Michael Bayer mike...@zzzcomputing.com wrote: you have every reason to be confused by that paragraph, which is using way too much terminology to express what’s important there. at some point, we had to add a behavior which I thought would be confusing to people, so that paragraph tries badly to explain what it is. I should replace it with just a simple sentence and an example. Here’s the example: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) bs = relationship(B) class B(Base): __tablename__ = 'b' id = Column(Integer, primary_key=True) a_id = Column(Integer, ForeignKey('a.id')) e = create_engine(sqlite://, echo=True) Base.metadata.create_all(e) sess = Session(e) a1 = A() b1 = B() a1.bs = [b1] sess.add(a1) sess.commit() a1.bs # refresh a1.bs sess.close() # close out - sess is no longer associated with a1, b1 # all new session sess2 = Session(e) a1.bs.remove(b1) sess2.add(a1) # b1 was removed from a1.bs, but # is in sess2 anyway! surprising! assert b1 in sess2 # because we need it for the flush, it's still here: from sqlalchemy import inspect print inspect(a1).attrs.bs.history.deleted On Mar 15, 2014, at 5:26 AM, Bao Niu niuba...@gmail.com wrote: I've read this paragraph (http://docs.sqlalchemy.org/en/latest/orm/session.html#unitofwork-cascades) many many times and still can't think of a practical example of what is being discussed. save-update cascade also cascades the pending history of the target attribute, meaning that objects which were removed from a scalar or collection attribute whose changes have not yet been flushed are also placed into the target session. This is because they may have foreign key attributes present which will need to be updated to no longer refer to the parent. I don't think my English is the main stumbling block here because I understand the meaning of each word, but as soon as I'm putting them together I'm completely lost. Could someone give a simple example here to illustrate the main point in this paragraph please? Highly appreciated. Thanks. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] Docs in PDF are not being generated
Standardization is always necessary, just a question, which tool would you suggest for converting things to PDF? Sent from my iBath On Jan 30, 2013, at 20:16, Michael Bayer mike...@zzzcomputing.com wrote: Keep in mind were ideally working with readthedocs standard tools. It really should be possible for this to all work using standard approaches. Sent from my iPhone On Jan 30, 2013, at 12:50 PM, Werner werner.bru...@sfr.fr wrote: On 30/01/2013 17:53, Michael Bayer wrote: On Jan 30, 2013, at 10:10 AM, Vraj Mohan wrote: Is there any interest in having this fixed? I'd love someone to take it on and fix it, sure.I've been asking around for help for years, as I still see people publishing entire books with LaTeX. What about rst2pdf instead of going via LaTex? http://techtonik.rainforce.org/2010/05/sphinx-pdf-with-rst2pdf.html I used on smallish docs, so don't know how it will do with SQLAlchemy. Werner -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
RE: [sqlalchemy] tsvector
cool, thanks a lot for the info, I'll check that. __ 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: mike...@zzzcomputing.com Subject: Re: [sqlalchemy] tsvector Date: Wed, 5 Dec 2012 18:31:37 -0500 To: sqlalchemy@googlegroups.com sanjay's approach there is hardcoded SQL which isn't necessary with SQLAlchemy (though always supported as a quick approach to something). tsvector here as a type can be implemented with UserDefinedType: http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#sqlalchemy.types.UserDefinedType and the operators I see at http://www.postgresql.org/docs/8.3/static/functions-textsearch.html can be implemented using op(): column.op('@@@')(func.to_tsvector(some value)) that's a little verbose, so those operations can be implemented as operators that are part of the tsvector type, using the techniques described at http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#redefining-and-creating-new-operators . All of this can and should be part of SQLAlchemy at some point, with external types like these we usually rely on volunteers, such as the recent HSTORE contribution. The HSTORE module here is a great place to see an example of a richly functional type: http://hg.sqlalchemy.org/sqlalchemy/file/4abc02fbc36b/lib/sqlalchemy/dialects/postgresql/hstore.py On Dec 5, 2012, at 5:37 PM, Gery . wrote:I was searching in google about tsvector (postgresql) implemented in sqlalchemy or geoalchemy but seems to me that it's not implemented yet. After searching for it in [1], it didn't matchanything. Sanjay, however, gives a way to do this [2] but seems confusing to me, is it possible to use this tsvector as simple as someone using types such as integer, small integer, etc etc? if so, it'd be cool to know how. Thanks, [1] http://docs.sqlalchemy.org/en/rel_0_8/search.html?q=tsvectorcheck_keywords=yesarea=default [2] https://groups.google.com/forum/?fromgroups=#!topic/sqlalchemy/Dns28KksD-4 __ 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. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] tsvector
I was searching in google about tsvector (postgresql) implemented in sqlalchemy or geoalchemy but seems to me that it's not implemented yet. After searching for it in [1], it didn't match anything. Sanjay, however, gives a way to do this [2] but seems confusing to me, is it possible to use this tsvector as simple as someone using types such as integer, small integer, etc etc? if so, it'd be cool to know how. Thanks, [1] http://docs.sqlalchemy.org/en/rel_0_8/search.html?q=tsvectorcheck_keywords=yesarea=default [2] https://groups.google.com/forum/?fromgroups=#!topic/sqlalchemy/Dns28KksD-4 __ 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. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
RE: [sqlalchemy] can't adapt type 'centroid'
Thanks Mike, I tried it but it seems this mailing list is not working, someone knows if it does? From: mike...@zzzcomputing.com Subject: Re: [sqlalchemy] can't adapt type 'centroid' Date: Mon, 26 Nov 2012 20:43:04 -0500 To: sqlalchemy@googlegroups.com trying to get the attention of the geoalchemy guy here, maybe try their list: https://groups.google.com/forum/?fromgroups#!forum/geoalchemy -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
RE: [sqlalchemy] can't adapt type 'centroid'
it does, thanks From: gameji...@hotmail.com To: sqlalchemy@googlegroups.com Subject: RE: [sqlalchemy] can't adapt type 'centroid' Date: Tue, 27 Nov 2012 08:47:53 + Thanks Mike, I tried it but it seems this mailing list is not working, someone knows if it does? From: mike...@zzzcomputing.com Subject: Re: [sqlalchemy] can't adapt type 'centroid' Date: Mon, 26 Nov 2012 20:43:04 -0500 To: sqlalchemy@googlegroups.com trying to get the attention of the geoalchemy guy here, maybe try their list: https://groups.google.com/forum/?fromgroups#!forum/geoalchemy -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] can't adapt type 'centroid'
Hi all, newbie question here, I'm getting this error message: *** $ python model.py /usr/lib64/python2.6/site-packages/sqlalchemy/engine/reflection.py:47: SAWarning: Did not recognize type 'geometry' of column 'geom' ret = fn(self, con, *args, **kw) DB Columns ['forearc_basins_polygon_wgs84.name', 'forearc_basins_polygon_wgs84.perim_km', 'forearc_basins_polygon_wgs84.area_km2', 'forearc_basins_polygon_wgs84.hectare_ha', 'forearc_basins_polygon_wgs84.source', 'forearc_basins_polygon_wgs84.comments', 'forearc_basins_polygon_wgs84.geom', 'forearc_basins_polygon_wgs84.id', 'forearc_basins_polygon_wgs84.fid'] GeoColumn Type ST_Polygon Traceback (most recent call last): File model.py, line 66, in module lon = session.scalar(center.x) File /usr/lib64/python2.6/site-packages/sqlalchemy/orm/session.py, line 915, in scalar return self.execute(clause, params=params, mapper=mapper, bind=bind, **kw).scalar() File /usr/lib64/python2.6/site-packages/sqlalchemy/orm/session.py, line 910, in execute clause, params or {}) File /usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py, line 1449, in execute params) File /usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py, line 1493, in _execute_function multiparams, params) File /usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py, line 1584, in _execute_clauseelement compiled_sql, distilled_params File /usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py, line 1698, in _execute_context context) File /usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py, line 1691, in _execute_context context) File /usr/lib64/python2.6/site-packages/sqlalchemy/engine/default.py, line 331, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.ProgrammingError: (ProgrammingError) can't adapt type 'centroid' 'SELECT ST_X((%(param_1)s)) AS x_1' {'param_1': geoalchemy.functions.centroid at 0x1cb45cd0; centroid} *** using this script: *** import sys from sqlalchemy import * from sqlalchemy.orm import * from geoalchemy import * from sqlalchemy.sql import func db = postgresql://postgres:jeniusj@localhost:5432/mop engine = create_engine(db, echo=False) metadata = MetaData() source = Table('forearc_basins_polygon_wgs84', metadata, GeometryExtensionColumn('geom', Geometry(3)), autoload=True, autoload_with=engine ) Session = sessionmaker(bind=engine) session = Session() q = session.query(source) row = q.order_by(desc(st_area(geom))).first()# largest polygon print DB Columns, source.columns print GeoColumn Type, session.scalar(functions.geometry_type(row.geom)) center = DBSpatialElement(row.geom.centroid()) lon = session.scalar(center.x) lat = session.scalar(center.y) area = session.scalar(DBSpatialElement(row.geom.area())) print row.name, centroid is at:, lon, ,, lat, and this big, area *** I read that this could be a psycopg2 problem, however I have the latest version (2.4.5 instead of 2.0.6.3 where the error was found). What could be wrong? ideas are welcome, thanks. PS. my configuration: RHEL5 (64-bits) python2.6 (rpm from EPEL) # d /usr/lib/python2.6/site-packages/ total 99k -rw-r--r-- 1 root root 34 Nov 20 10:09 setuptools.pth -rw-r--r-- 1 root root 144 Nov 20 10:09 setuptools-0.6c11-py2.6.egg-info -rw-r--r-- 1 root root 215 Nov 20 10:09 easy-install.pth drwxr-xr-x 5 root root 4.1k Nov 20 10:09 distribute-0.6.30-py2.6.egg/ drwxr-xr-x 2 root root 4.1k Nov 20 10:10 pip-1.2.1-py2.6.egg-info/ drwxr-xr-x 4 root root 4.1k Nov 20 10:10 pip/ drwxr-xr-x 2 root root 4.1k Nov 20 10:10 simplejson-2.6.2-py2.6.egg-info/ drwxr-xr-x 3 root root 4.1k Nov 20 10:10 simplejson/ drwxr-xr-x 2 root root 4.1k Nov 20 10:11 Markdown-2.2.1-py2.6.egg-info/ drwxr-xr-x 3 root root 4.1k Nov 20 10:11 markdown/ drwxr-xr-x 4 root root 4.1k Nov 20 10:43 ../ drwxr-xr-x 2 root root 4.1k Nov 20 11:30 Pygments-1.5-py2.6.egg-info/ drwxr-xr-x 6 root root 4.1k Nov 20 11:30 pygments/ drwxr-xr-x 2 root root 4.1k Nov 21 10:10 pyquery-1.2.2-py2.6.egg-info/ drwxr-xr-x 2 root root 4.1k Nov 21 10:10 pyquery/ drwxr-xr-x 2 root root 4.1k Nov 21 10:10 cssselect-0.7.1-py2.6.egg-info/ drwxr-xr-x 2 root root 4.1k Nov 21 10:10 cssselect/ drwxr-xr-x 2 root root 4.1k Nov 21 10:17 shortuuid-0.2-py2.6.egg-info/ drwxr-xr-x 2 root root 4.1k Nov 21 10:17 shortuuid/ drwxr-xr-x 2 root root 4.1k Nov 21 10:50 dxfwrite-1.2.0-py2.6.egg-info/ drwxr-xr-x 3 root root 4.1k Nov 21 10:50 dxfwrite/ drwxr-xr-x 2 root root 4.1k Nov 26 13:14 GeoAlchemy-0.7.1-py2.6.egg-info/ drwxr-xr-x 3 root root 4.1k Nov 26 13:14 geoalchemy/ drwxr-xr-x 21 root root 4.1k Nov 26 13:14 ./ # d /usr/lib64/python2.6/site-packages/ total 87k -rw-r--r-- 1 root root 119 Apr 12 2012 README drwxr-xr-x 23 root root 21k Nov 20 10:10 ../ drwxr-xr-x 2 root root 4.1k Nov 20 11:11 psycopg2-2.4.5-py2.6.egg-info/ drwxr-xr-x
RE: [sqlalchemy] live access to postgis database to use in ExtJS, OpenLayers, etc
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: sqlalchemy@googlegroups.com On Tue, Oct 2, 2012 at 7:26 PM, Gery . gameji...@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 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
RE: [sqlalchemy] live access to postgis database to use in ExtJS, OpenLayers, etc
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 To: sqlalchemy@googlegroups.com On Mon, Oct 1, 2012 at 11:38 PM, Gery . gameji...@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 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] __main__ error
Hello, I'm quite new in SA and I'm having some problems with a script. After running the script, I'm getting this error: [__main__.Boreholes object at 0xb7a2958c, __main__.Boreholes object at 0xb7a2962c, __main__.Boreholes object at 0xb7a2966c, __main__.Boreholes object at 0xb7a296cc, __main__.Boreholes object at 0xb7a2972c, __main__.Boreholes object at 0xb7a2978c, __main__.Boreholes object at 0xb7a297ec, __main__.Boreholes object at 0xb7a2984c, __main__.Boreholes object at 0xb7a298ac, __main__.Boreholes object at 0xb7a2990c, __main__.Boreholes object at 0xb7a2996c, __main__.Boreholes object at 0xb7a299cc, __main__.Boreholes object at 0xb7a29a2c, __main__.Boreholes object at 0xb7a29a8c, __main__.Boreholes object at 0xb7a29aec, __main__.Boreholes object at 0xb7a29b4c, __main__.Boreholes object at 0xb7a29bac, __main__.Boreholes object at 0xb7a29c2c, __main__.Boreholes object at 0xb7a29cac, __main__.Boreholes object at 0xb7a29d2c, __main__.Boreholes object at 0xb7a29dac, __main__.Boreholes object at 0xb7a29e2c, __main__.Boreholes object at 0xb7a29eac, __main__.Boreholes object at 0xb7a29f2c, __main__.Boreholes object at 0xb7a29fac, __main__.Boreholes object at 0xb7a3504c, __main__.Boreholes object at 0xb7a350cc, __main__.Boreholes object at 0xb7a3514c, __main__.Boreholes object at 0xb7a351cc, __main__.Boreholes object at 0xb7a3524c, __main__.Boreholes object at 0xb7a352cc, __main__.Boreholes object at 0xb7a3534c, __main__.Boreholes object at 0xb7a353cc, __main__.Boreholes object at 0xb7a3544c, __main__.Boreholes object at 0xb7a354cc, __main__.Boreholes object at 0xb7a3554c, __main__.Boreholes object at 0xb7a355cc, __main__.Boreholes object at 0xb7a3564c, __main__.Boreholes object at 0xb7a356cc, __main__.Boreholes object at 0xb7a3574c, __main__.Boreholes object at 0xb7a357cc, __main__.Boreholes object at 0xb7a3584c, __main__.Boreholes object at 0xb7a358cc, __main__.Boreholes object at 0xb7a3594c, __main__.Boreholes object at 0xb7a359cc, __main__.Boreholes object at 0xb7a35a4c, __main__.Boreholes object at 0xb7a35acc, __main__.Boreholes object at 0xb7a35b4c, __main__.Boreholes object at 0xb7a35bcc, __main__.Boreholes object at 0xb7a35c4c, __main__.Boreholes object at 0xb7a35ccc] the script is here: * # import things to be used from sqlalchemy import create_engine, MetaData, Table from sqlalchemy.orm import mapper, sessionmaker # connecting to database engine myengine = create_engine('postgresql://postgres:pass@localhost:5432/mop', echo=False) # MetaData: describing the database schema mymetadata = MetaData(myengine) # load existing tables in postgis database boreholes = Table('boreholes_point_wgs84', mymetadata, autoload=True) # defining empty classes to be mapped to existing tables class Boreholes(object): pass # mapping empty classes to existing tables [ie. ORM] Boreholesmapper = mapper(Boreholes, boreholes) # session operations [finding data, adding data, modifying data and deleting data] Session = sessionmaker(bind=myengine) mysession = Session() # queries alldata = mysession.query(Boreholes).all() print alldata * I'm working with python2.4 and SA 0.7.8 in rhel5 (32-bit). Any hint is appreciated, Best regards, 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. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
RE: [sqlalchemy] __main__ error
thanks Robert, using your suggestion I get: ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_sa_class_manager', '_sa_instance_state', u'comments', u'core_rec_m', u'fid', u'geom', u'h_f_mwm2', u'id', u'latitude', u'longitude', u'max_pen_m', u'source', u'station', u'survey', u't_g_ckm1', u'type', u'w_depth_m'] so you were right, but one question, when I use: ** # starting with ORM: declarative base class [catalog of classes mapped to database tables relative to this base] mybase = declarative_base(metadata=mymetadata) # defining classes to be mapped class Boreholes(mybase): __tablename__ = 'boreholes_point_wgs84' __table_args__ = {'autoload':True} def __init__ (self, id, fid, longitude, latitude, w_depth_m, station, type, survey, source, max_pen_m, core_rec_m, t_g_ckm1, h_f_mwm2, comments): self.id = id self.fid = fid self.longitude = longitude self.latitude = latitude self.w_depth_m = w_depth_m self.station = station self.type = type self.survey = survey self.source = source self.max_pen_m = max_pen_m self.core_rec_m = core_rec_m self.t_g_ckm1 = t_g_ckm1 self.h_f_mwm2 = h_f_mwm2 self.comments = comments def __repr__ (self): return Boreholes(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) % (self.id, self.fid, self.longitude, self.latitude, self.w_depth_m, self.station, self.type, self.survey, self.source, self.max_pen_m, self.core_rec_m, self.t_g_ckm1, self.h_f_mwm2, self.comments) ** whit the same print.alldata I can output all the rows, but in this way I don't know how to make the mapper(Boreholes, boreholes) I used in the first place. Is it possible to print all the rows with my original code? Thanks, 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. Date: Wed, 29 Aug 2012 13:05:18 +0200 Subject: Re: [sqlalchemy] __main__ error From: xrotw...@googlemail.com To: sqlalchemy@googlegroups.com doesn't look like an error to me. It's just the result of your print alldata call. It depends on Postgis which attributes are available on the Borehole instances, but you could use print dir(alldata[0]) to get an idea about what is available. On Wed, Aug 29, 2012 at 12:37 PM, Gery . gameji...@hotmail.com wrote: Hello, I'm quite new in SA and I'm having some problems with a script. After running the script, I'm getting this error: [__main__.Boreholes object at 0xb7a2958c, __main__.Boreholes object at 0xb7a2962c, __main__.Boreholes object at 0xb7a2966c, __main__.Boreholes object at 0xb7a296cc, __main__.Boreholes object at 0xb7a2972c, __main__.Boreholes object at 0xb7a2978c, __main__.Boreholes object at 0xb7a297ec, __main__.Boreholes object at 0xb7a2984c, __main__.Boreholes object at 0xb7a298ac, __main__.Boreholes object at 0xb7a2990c, __main__.Boreholes object at 0xb7a2996c, __main__.Boreholes object at 0xb7a299cc, __main__.Boreholes object at 0xb7a29a2c, __main__.Boreholes object at 0xb7a29a8c, __main__.Boreholes object at 0xb7a29aec, __main__.Boreholes object at 0xb7a29b4c, __main__.Boreholes object at 0xb7a29bac, __main__.Boreholes object at 0xb7a29c2c, __main__.Boreholes object at 0xb7a29cac, __main__.Boreholes object at 0xb7a29d2c, __main__.Boreholes object at 0xb7a29dac, __main__.Boreholes object at 0xb7a29e2c, __main__.Boreholes object at 0xb7a29eac, __main__.Boreholes object at 0xb7a29f2c, __main__.Boreholes object at 0xb7a29fac, __main__.Boreholes object at 0xb7a3504c, __main__.Boreholes object at 0xb7a350cc, __main__.Boreholes object at 0xb7a3514c, __main__.Boreholes object at 0xb7a351cc, __main__.Boreholes object at 0xb7a3524c, __main__.Boreholes object at 0xb7a352cc, __main__.Boreholes object at 0xb7a3534c, __main__.Boreholes object at 0xb7a353cc, __main__.Boreholes object at 0xb7a3544c, __main__.Boreholes object at 0xb7a354cc, __main__.Boreholes object at 0xb7a3554c, __main__.Boreholes object at 0xb7a355cc, __main__.Boreholes object at 0xb7a3564c, __main__.Boreholes
RE: [sqlalchemy] __main__ error
Thanks Simon, that's the way, it works well, but is it possible to output all the tables without specifying every column? Thanks, 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, 29 Aug 2012 12:19:42 +0100 Subject: Re: [sqlalchemy] __main__ error To: sqlalchemy@googlegroups.com On Wed, Aug 29, 2012 at 11:37 AM, Gery . gameji...@hotmail.com wrote: Hello, I'm quite new in SA and I'm having some problems with a script. After running the script, I'm getting this error: [__main__.Boreholes object at 0xb7a2958c, __main__.Boreholes object at 0xb7a2962c, __main__.Boreholes object at 0xb7a2966c, __main__.Boreholes object at 0xb7a296cc, __main__.Boreholes object at 0xb7a2972c, __main__.Boreholes object at 0xb7a2978c, __main__.Boreholes object at 0xb7a297ec, __main__.Boreholes object at 0xb7a2984c, __main__.Boreholes object at 0xb7a298ac, __main__.Boreholes object at 0xb7a2990c, __main__.Boreholes object at 0xb7a2996c, __main__.Boreholes object at 0xb7a299cc, __main__.Boreholes object at 0xb7a29a2c, __main__.Boreholes object at 0xb7a29a8c, __main__.Boreholes object at 0xb7a29aec, __main__.Boreholes object at 0xb7a29b4c, __main__.Boreholes object at 0xb7a29bac, __main__.Boreholes object at 0xb7a29c2c, __main__.Boreholes object at 0xb7a29cac, __main__.Boreholes object at 0xb7a29d2c, __main__.Boreholes object at 0xb7a29dac, __main__.Boreholes object at 0xb7a29e2c, __main__.Boreholes object at 0xb7a29eac, __main__.Boreholes object at 0xb7a29f2c, __main__.Boreholes object at 0xb7a29fac, __main__.Boreholes object at 0xb7a3504c, __main__.Boreholes object at 0xb7a350cc, __main__.Boreholes object at 0xb7a3514c, __main__.Boreholes object at 0xb7a351cc, __main__.Boreholes object at 0xb7a3524c, __main__.Boreholes object at 0xb7a352cc, __main__.Boreholes object at 0xb7a3534c, __main__.Boreholes object at 0xb7a353cc, __main__.Boreholes object at 0xb7a3544c, __main__.Boreholes object at 0xb7a354cc, __main__.Boreholes object at 0xb7a3554c, __main__.Boreholes object at 0xb7a355cc, __main__.Boreholes object at 0xb7a3564c, __main__.Boreholes object at 0xb7a356cc, __main__.Boreholes object at 0xb7a3574c, __main__.Boreholes object at 0xb7a357cc, __main__.Boreholes object at 0xb7a3584c, __main__.Boreholes object at 0xb7a358cc, __main__.Boreholes object at 0xb7a3594c, __main__.Boreholes object at 0xb7a359cc, __main__.Boreholes object at 0xb7a35a4c, __main__.Boreholes object at 0xb7a35acc, __main__.Boreholes object at 0xb7a35b4c, __main__.Boreholes object at 0xb7a35bcc, __main__.Boreholes object at 0xb7a35c4c, __main__.Boreholes object at 0xb7a35ccc] the script is here: * # import things to be used from sqlalchemy import create_engine, MetaData, Table from sqlalchemy.orm import mapper, sessionmaker # connecting to database engine myengine = create_engine('postgresql://postgres:pass@localhost:5432/mop', echo=False) # MetaData: describing the database schema mymetadata = MetaData(myengine) # load existing tables in postgis database boreholes = Table('boreholes_point_wgs84', mymetadata, autoload=True) # defining empty classes to be mapped to existing tables class Boreholes(object): pass # mapping empty classes to existing tables [ie. ORM] Boreholesmapper = mapper(Boreholes, boreholes) # session operations [finding data, adding data, modifying data and deleting data] Session = sessionmaker(bind=myengine) mysession = Session() # queries alldata = mysession.query(Boreholes).all() print alldata * I'm working with python2.4 and SA 0.7.8 in rhel5 (32-bit). Any hint is appreciated, Best regards, Gery That's not an error - that is a list of instances of the Borehole class, which is what you get back from Query.all(). The columns in your boreholes_point_wgs84 become properties of those instances. So for example if the table has name, latitude and longitude columns, you would be able to change your last 2 lines to say something like: for borehole in mysession.query(Boreholes).all(): print borehole.name, borehole.latitude, borehole.longitude Hope that helps, Simon -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send
RE: [sqlalchemy] __main__ error
That was really helpful Robert, it works nicely, how could I modify this code to get geojson format? is it possible in this way or is there a better approach? __ 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. Date: Wed, 29 Aug 2012 13:28:44 +0200 Subject: Re: [sqlalchemy] __main__ error From: xrotw...@googlemail.com To: sqlalchemy@googlegroups.com for borehole in alldata: for attr in sorted(filter(lambda a: not a.startswith('_'), dir(borehole))): print attr, getattr(borehole, attr) could do the trick On Wed, Aug 29, 2012 at 1:24 PM, Gery . gameji...@hotmail.com wrote: thanks Robert, using your suggestion I get: ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_sa_class_manager', '_sa_instance_state', u'comments', u'core_rec_m', u'fid', u'geom', u'h_f_mwm2', u'id', u'latitude', u'longitude', u'max_pen_m', u'source', u'station', u'survey', u't_g_ckm1', u'type', u'w_depth_m'] so you were right, but one question, when I use: ** # starting with ORM: declarative base class [catalog of classes mapped to database tables relative to this base] mybase = declarative_base(metadata=mymetadata) # defining classes to be mapped class Boreholes(mybase): __tablename__ = 'boreholes_point_wgs84' __table_args__ = {'autoload':True} def __init__ (self, id, fid, longitude, latitude, w_depth_m, station, type, survey, source, max_pen_m, core_rec_m, t_g_ckm1, h_f_mwm2, comments): self.id = id self.fid = fid self.longitude = longitude self.latitude = latitude self.w_depth_m = w_depth_m self.station = station self.type = type self.survey = survey self.source = source self.max_pen_m = max_pen_m self.core_rec_m = core_rec_m self.t_g_ckm1 = t_g_ckm1 self.h_f_mwm2 = h_f_mwm2 self.comments = comments def __repr__ (self): return Boreholes(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) % (self.id, self.fid, self.longitude, self.latitude, self.w_depth_m, self.station, self.type, self.survey, self.source, self.max_pen_m, self.core_rec_m, self.t_g_ckm1, self.h_f_mwm2, self.comments) ** whit the same print.alldata I can output all the rows, but in this way I don't know how to make the mapper(Boreholes, boreholes) I used in the first place. Is it possible to print all the rows with my original code? Thanks, 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. Date: Wed, 29 Aug 2012 13:05:18 +0200 Subject: Re: [sqlalchemy] __main__ error From: xrotw...@googlemail.com To: sqlalchemy@googlegroups.com doesn't look like an error to me. It's just the result of your print alldata call. It depends on Postgis which attributes are available on the Borehole instances, but you could use print dir(alldata[0]) to get an idea about what is available. On Wed, Aug 29, 2012 at 12:37 PM, Gery . gameji...@hotmail.com wrote: Hello, I'm quite new in SA and I'm having some problems with a script. After running the script, I'm getting this error: [__main__.Boreholes object at 0xb7a2958c, __main__.Boreholes object at 0xb7a2962c, __main__.Boreholes object at 0xb7a2966c, __main__.Boreholes object at 0xb7a296cc, __main__.Boreholes object at 0xb7a2972c, __main__.Boreholes object at 0xb7a2978c, __main__.Boreholes object at 0xb7a297ec, __main__.Boreholes object at 0xb7a2984c, __main__.Boreholes object at 0xb7a298ac, __main__.Boreholes object at 0xb7a2990c, __main__.Boreholes object at 0xb7a2996c, __main__.Boreholes object at 0xb7a299cc, __main__.Boreholes object at 0xb7a29a2c
RE: [sqlalchemy] __main__ error
cool, thanks Robert, I'll try that and see what comes up, 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. Date: Wed, 29 Aug 2012 13:54:49 +0200 Subject: Re: [sqlalchemy] __main__ error From: xrotw...@googlemail.com To: sqlalchemy@googlegroups.com you could create a method on the Boreholes mapper to convert an instance to geojson (which I assume to be some sort of dictionary): class Boreholes(mybase): ... def geojson(self): return dict([(attr, getattr(self, attr, None)) for attr in ['latitude', 'longitude', .. whatever else there is in geojson ...]]) On Wed, Aug 29, 2012 at 1:34 PM, Gery . gameji...@hotmail.com wrote: That was really helpful Robert, it works nicely, how could I modify this code to get geojson format? is it possible in this way or is there a better approach? __ 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. Date: Wed, 29 Aug 2012 13:28:44 +0200 Subject: Re: [sqlalchemy] __main__ error From: xrotw...@googlemail.com To: sqlalchemy@googlegroups.com for borehole in alldata: for attr in sorted(filter(lambda a: not a.startswith('_'), dir(borehole))): print attr, getattr(borehole, attr) could do the trick On Wed, Aug 29, 2012 at 1:24 PM, Gery . gameji...@hotmail.com wrote: thanks Robert, using your suggestion I get: ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_sa_class_manager', '_sa_instance_state', u'comments', u'core_rec_m', u'fid', u'geom', u'h_f_mwm2', u'id', u'latitude', u'longitude', u'max_pen_m', u'source', u'station', u'survey', u't_g_ckm1', u'type', u'w_depth_m'] so you were right, but one question, when I use: ** # starting with ORM: declarative base class [catalog of classes mapped to database tables relative to this base] mybase = declarative_base(metadata=mymetadata) # defining classes to be mapped class Boreholes(mybase): __tablename__ = 'boreholes_point_wgs84' __table_args__ = {'autoload':True} def __init__ (self, id, fid, longitude, latitude, w_depth_m, station, type, survey, source, max_pen_m, core_rec_m, t_g_ckm1, h_f_mwm2, comments): self.id = id self.fid = fid self.longitude = longitude self.latitude = latitude self.w_depth_m = w_depth_m self.station = station self.type = type self.survey = survey self.source = source self.max_pen_m = max_pen_m self.core_rec_m = core_rec_m self.t_g_ckm1 = t_g_ckm1 self.h_f_mwm2 = h_f_mwm2 self.comments = comments def __repr__ (self): return Boreholes(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) % (self.id, self.fid, self.longitude, self.latitude, self.w_depth_m, self.station, self.type, self.survey, self.source, self.max_pen_m, self.core_rec_m, self.t_g_ckm1, self.h_f_mwm2, self.comments) ** whit the same print.alldata I can output all the rows, but in this way I don't know how to make the mapper(Boreholes, boreholes) I used in the first place. Is it possible to print all the rows with my original code? Thanks, 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. Date: Wed, 29 Aug 2012 13:05:18 +0200 Subject: Re: [sqlalchemy] __main__ error From: xrotw...@googlemail.com To: sqlalchemy@googlegroups.com doesn't look like an error to me. It's just the result of your print alldata call. It depends on Postgis which attributes are available on the Borehole instances, but you could use
RE: [sqlalchemy] how to get into PG database, is the url the right way? newbie question
Thanks Martijn for your help, I understand that it doesn't really matter which technology someone uses on server side to deliver the data, so I can use SA or GeoSA to do this, is it correct? I also think that it only depends of what software someone is already using, well in my case OL, GeoExt, Ext, PG, is this right? So, as long as the data returned by the server side service is formatted as geojson (because point/line/polygon/etc... are stored in my PG db), I can use that data in the javascript in my web interface. I don't understand well your code, but it should reflect the above info. I've read that SA/GeoSA is difficult to understand at the beginning, but it's worth to learn because it can be a very strong toolkit to develop future projects. Well you're right about the tools, I'm using mod_wsgi after reading several things in internet, also the python DB API driver and now I can connect my PG tables with python, but so far I don't understand how to link this with OL protocol or GeoExt url. Thanks again for you answer and I'd be cool to have some further ideas about this. 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: mart...@xs4us.nu Subject: Re: [sqlalchemy] how to get into PG database, is the url the right way? newbie question Date: Sat, 18 Aug 2012 02:36:16 +0200 To: sqlalchemy@googlegroups.com or take a look at this: var store = new GeoExt.data.FeatureStore({ layer: sundials, proxy: new GeoExt.data.ProtocolProxy({ protocol: new OpenLayers.Protocol.HTTP({ url: sundials.kml, format: new OpenLayers.Format.KML() }) }), fields: [ {name: 'title', type: 'string'}, {name: 'description', type: 'string'} ], autoLoad: true }); which looks way different than your code…. use mod_python (better not)use mod_wsgi (Good!)use CGI of FastCGI (not that good) GeoExt uses ext 3.3 which is a hazzard in its own rights since 4.x is so much better (consistant) , faster and more stable, I guess GeoExt is over a year behind reality. If you use that try if you can wait for GeoExt2 On Aug 18, 2012, at 02:24 , Martijn Moeling mart...@xs4us.nu wrote:I have made this for my project and I do not see why you are using Openlayers for this.This has nothing to do with sqlalchemy. off topic: Ext.form.Panel has no 'protocol' so I think you should extend FormPanel to include that functionality. Ext.direct is the way to go for stuff like this. On Aug 14, 2012, at 19:05 , Gery geryherb...@gmail.com wrote: any ideas?? basically the idea is how to search inside a database being outside the database, especifically through SqlAlchemy from OpenLayers? On Monday, August 13, 2012 9:23:43 PM UTC+2, Gery wrote: Hello, I'm new around here and I've been using SQLalchemy (SA) for a while. I work with PostGis (PG), OpenLayers (OL), ExtJS, GeoExtJS and now with the great SA and GeoAlchemy. I have one problem, I created a model where I defined one table of my PG database, it has a url like this: url = 'postgresql://postgres:password@localhost:5432/pgdb'. In my HTML, I have some maps displayed with OL and a toolbar built with ExtJS and GeoExtJS. I put a search button there using ExtJS, and the OL protocol code to get the data. This protocol has an url option, in this way: var searchformPanel = new Ext.form.FormPanel( { width: 250, bodyStyle: 'padding:5px', labelAlign: 'top', defaults: { anchor: '100%' }, protocol: new OpenLayers.Protocol.HTTP( { url: 'http://localhost/mop/py/dbmodel.py', format: new OpenLayers.Format.GeoJSON() } ), items: etc,etc.. my problem is that in this url I wrote the whole path where my model script is located, but after pressing the button I got nothing. I think I need something else rather than only pointing the whole path and the python script in the url mentioned above, is that correct? I've searched how to connect sqlalchemy to extjs in google but didn't find any that solved this doubt. Any support is very welcome, thanks in advance. Best regards, Gery -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/06H8WaCTV7cJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy
RE: [sqlalchemy] Re: how to get into PG database, is the url the right way? newbie question
Thanks Simon again for your nice explanation, I finally found a way to do that, thanks. 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: Tue, 14 Aug 2012 19:14:36 +0100 Subject: Re: [sqlalchemy] Re: how to get into PG database, is the url the right way? newbie question To: sqlalchemy@googlegroups.com On Tue, Aug 14, 2012 at 6:39 PM, Gery geryherb...@gmail.com wrote: Hello Simon, Thanks for your answer, acttually I don't use any web framework, I just did a html page and put Openlayers, GeoExt, and Ext code there. To display points/lines/polylines/rasters/etc., I use Mapserver, so I connect my PostGis database with OpenLayers. After putting the http://localhost/mop/py/dbmodel.py link, I get the whole model (I think this should be my model, is it right?), so the Apache works well =): #created: 30 July 2012 #updated: 12 August 2012 #Gery from sqlalchemy import * from sqlachemy import create_engine, MetaData, Table from sqlalchemy.orm import * from sqlalchemy.orm import mapper, relation, backref, sessionmaker from sqlalchemy.ext.declarative import declarative_base # Setup the url, database engine and session url = 'postgresql://postgres:password@localhost:5432/mop' engine = create_engine(url, echo=True) session = sessionmaker(bind=engine) session = Session() # Setup the declarative extension and metadata Base = declarative_base(metadata=metadata) metadata = MetaData(engine) # Define the model classes class Boreholes(Base): __tablename__ = 'boreholes_point_wgs84' __table_args__ = {'autoload':True} # DDL Extensions for geometry specific DDL GeometryDDL(Boreholes.__table__) Do I really need a web framework? I know some people use GeoAlchemy and SqlAlchemy with Pylons, but I don't want to use that, well in general any web framework. What could it be that something you mentioned that I need? I've been reading that with PHP I can make the connection to do the HTTP requests/responds, am I right? is this the unique way or solution to do this? Thanks again Hi Gery, At the moment, your javascript code (running in your web browser) is making an HTTP request to Apache. Apache is simply returning the contents of the requested file, so your javascript is receiving a string of Python code that it has no way of interpreting. I'm afraid this will never work. What you need is for Apache to *execute* the python script and return the contents to your browser. There are lots of ways of doing this, but you'll really need to at least have a basic understanding of web technologies. You will have to understand how OpenLayers requests data from the server, know how to extract query parameters from the request, turn those into a database query, format the results as JSON and return them back to the browser. I'm afraid all of those things are outside the scope of this list. Sorry I can't be more help, Simon -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: how to get into PG database, is the url the right way? newbie question
any ideas?? basically the idea is how to search inside a database being outside the database, especifically through SqlAlchemy from OpenLayers? On Monday, August 13, 2012 9:23:43 PM UTC+2, Gery wrote: Hello, I'm new around here and I've been using SQLalchemy (SA) for a while. I work with PostGis (PG), OpenLayers (OL), ExtJS, GeoExtJS and now with the great SA and GeoAlchemy. I have one problem, I created a model where I defined one table of my PG database, it has a url like this: url = 'postgresql://postgres:password@localhost:5432/pgdb'. In my HTML, I have some maps displayed with OL and a toolbar built with ExtJS and GeoExtJS. I put a search button there using ExtJS, and the OL protocol code to get the data. This protocol has an url option, in this way: var searchformPanel = new Ext.form.FormPanel( { width: 250, bodyStyle: 'padding:5px', labelAlign: 'top', defaults: { anchor: '100%' }, protocol: new OpenLayers.Protocol.HTTP( { url: 'http://localhost/mop/py/dbmodel.py', format: new OpenLayers.Format.GeoJSON() } ), items: etc,etc.. my problem is that in this url I wrote the whole path where my model script is located, but after pressing the button I got nothing. I think I need something else rather than only pointing the whole path and the python script in the url mentioned above, is that correct? I've searched how to connect sqlalchemy to extjs in google but didn't find any that solved this doubt. Any support is very welcome, thanks in advance. Best regards, Gery -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/06H8WaCTV7cJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Re: how to get into PG database, is the url the right way? newbie question
Hello Simon, Thanks for your answer, acttually I don't use any web framework, I just did a html page and put Openlayers, GeoExt, and Ext code there. To display points/lines/polylines/rasters/etc., I use Mapserver, so I connect my PostGis database with OpenLayers. After putting the http://localhost/mop/py/dbmodel.py link, I get the whole model (I think this should be my model, is it right?), so the Apache works well =): #created: 30 July 2012 #updated: 12 August 2012 #Gery from sqlalchemy import * from sqlachemy import create_engine, MetaData, Table from sqlalchemy.orm import * from sqlalchemy.orm import mapper, relation, backref, sessionmaker from sqlalchemy.ext.declarative import declarative_base # Setup the url, database engine and session url = 'postgresql://postgres:password@localhost:5432/mop' engine = create_engine(url, echo=True) session = sessionmaker(bind=engine) session = Session() # Setup the declarative extension and metadata Base = declarative_base(metadata=metadata) metadata = MetaData(engine) # Define the model classes class Boreholes(Base): __tablename__ = 'boreholes_point_wgs84' __table_args__ = {'autoload':True} # DDL Extensions for geometry specific DDL GeometryDDL(Boreholes.__table__) Do I really need a web framework? I know some people use GeoAlchemy and SqlAlchemy with Pylons, but I don't want to use that, well in general any web framework. What could it be that something you mentioned that I need? I've been reading that with PHP I can make the connection to do the HTTP requests/responds, am I right? is this the unique way or solution to do this? Thanks again I'm probably missing something here, but are you running any kind of web framework? What happens when you visit http://localhost/mop/py/dbmodel.py in your web browser? You need something running on the server which accepts HTTP requests and responds with whatever data OpenLayers is expecting. There are plenty of web frameworks to choose from (http://wiki.python.org/moin/WebFrameworks/) - I happen to like Pyramid, but you may want to start with something smaller such as Flask. Hope that helps, Simon -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/M6kFU5TjOsAJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
RE: [sqlalchemy] Re: how to get into PG database, is the url the right way? newbie question
Many thanks Simon, very cool explanation, I'm grateful for your neat support. I'll look for that in google and OpenLayers, about to execute the python script and Apache, I think it has something to do with modwsgi but not sure. If you could point me to some useful links for any of the ways (perahps the easiest one) of doing this, I'd be really grateful, but you already helped me a lot, thanks man. Cheers, Gery Hi Gery, At the moment, your javascript code (running in your web browser) is making an HTTP request to Apache. Apache is simply returning the contents of the requested file, so your javascript is receiving a string of Python code that it has no way of interpreting. I'm afraid this will never work. What you need is for Apache to *execute* the python script and return the contents to your browser. There are lots of ways of doing this, but you'll really need to at least have a basic understanding of web technologies. You will have to understand how OpenLayers requests data from the server, know how to extract query parameters from the request, turn those into a database query, format the results as JSON and return them back to the browser. I'm afraid all of those things are outside the scope of this list. Sorry I can't be more help, Simon -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] how to get into PG database, is the url the right way? newbie question
Hello, I'm new around here and I've been using SQLalchemy (SA) for a while. I work with PostGis (PG), OpenLayers (OL), ExtJS, GeoExtJS and now with the great SA and GeoAlchemy. I have one problem, I created a model where I defined one table of my PG database, it has a url like this: url = 'postgresql://postgres:password@localhost:5432/pgdb'. In my HTML, I have some maps displayed with OL and a toolbar built with ExtJS and GeoExtJS. I put a search button there using ExtJS, and the OL protocol code to get the data. This protocol has an url option, in this way: var searchformPanel = new Ext.form.FormPanel( { width: 250, bodyStyle: 'padding:5px', labelAlign: 'top', defaults: { anchor: '100%' }, protocol: new OpenLayers.Protocol.HTTP( { url: 'http://localhost/mop/py/dbmodel.py', format: new OpenLayers.Format.GeoJSON() } ), items: etc,etc.. my problem is that in this url I wrote the whole path where my model script is located, but after pressing the button I got nothing. I think I need something else rather than only pointing the whole path and the python script in the url mentioned above, is that correct? I've searched how to connect sqlalchemy to extjs in google but didn't find any that solved this doubt. Any support is very welcome, thanks in advance. Best regards, Gery -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/7GJay8SzKUUJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.