Re: [sqlalchemy] how to get into PG database, is the "url" the right way? newbie question
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 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 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+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.
Re: [sqlalchemy] how to get into PG database, is the "url" the right way? newbie question
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 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+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] 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 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.
Re: [sqlalchemy] Re: How to disable Foreign Keys to clear database
Thanks so much! that worked great. It seems like google directed me everywhere except to the recipes. On Fri, Aug 17, 2012 at 4:32 AM, GHZ wrote: > There is a recipe for dropping FK constraints: > > http://www.sqlalchemy.org/trac/wiki/UsageRecipes > > did you find that? > > In addition, if you wanted to keep the FKs enabled, there is an example here > using Metadata.sorted_tables, to get the table list in dependency order. > > http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html?highlight=sorted_tables#reflecting-all-tables-at-once > > > On Friday, August 17, 2012 4:48:10 AM UTC+2, Greg wrote: >> >> Hi, >> >> I was naively trying to clear a db earlier in the day and I ran into this >> problem: 'Cannot delete or update a parent row: a foreign key constraint >> fails' >> >> So as anyone would do I've been searching online and through the >> documentation on how to turn the foreign keys off, on delete = Cascade, >> delete orphan-cascade what have you. So many hours and many stack traces >> later I'd like to ask your help in this matter >> >>> def cleanMapping(self, dbName): >>> >>> connection = self.dbEngines[dbName].connect() >>> trans = connection.begin() >>> >>> for my_table in reversed(self.dbMetaData[dbName].tables.values()): >>> keys= my_table.foreign_keys >>> for column in my_table.columns: >>> for key in keys: >>> >>>my_table = Table(my_table, self.dbMetaData[dbName], >>>Column(column, Integer, >>>ForeignKey(key, onupdate="CASCADE", ondelete = >>> "CASCADE") >>>,primary_key=True)) >>>connection.execute(my_table.delete()) >>> >>> trans.commit() >> >> >> So I'm fresh out of ideas; Everytime I try using this code I get >> "sqlalchemy.exc.ArgumentError: Column object already assigned to Table >> " >> >> > -- > 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/-/6EiRPIEPIHAJ. > > 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] unable to lock for update results in ResourceClosedError
a similar case was seen recently and it's a MySQLdb bug. closed here: http://www.sqlalchemy.org/trac/ticket/2536 here's the mySQLdb issue, hasn't been commented on by the developers yet: http://sourceforge.net/tracker/?func=detail&aid=3546166&group_id=22307&atid=374932 On Aug 17, 2012, at 4:03 AM, Chris Withers wrote: > Hi All, > > Has anyone else seen this using SQLAlchemy with MySQL? > I believe something else has the table the model is mapped to locked, but > this error doesn't make a lot of sense. Is this something that's been fixed > in a later version? > >for request in session.query(SomeModel).with_lockmode('update').all(): > File > "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/orm/query.py", line > 1579, in all >return list(self) > File > "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/orm/query.py", line > 1791, in instances >fetch = cursor.fetchall() > File > "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", > line 2498, in fetchall >l = self.process_rows(self._fetchall_impl()) > File > "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", > line 2467, in _fetchall_impl >self._non_result() > File > "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", > line 2472, in _non_result >"This result object does not return rows. " > sqlalchemy.exc.ResourceClosedError: This result object does not return rows. > It has been closed automatically. > > cheers, > > Chris > > -- > 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 disable Foreign Keys to clear database
There is a recipe for dropping FK constraints: http://www.sqlalchemy.org/trac/wiki/UsageRecipes did you find that? In addition, if you wanted to keep the FKs enabled, there is an example here using Metadata.sorted_tables, to get the table list in dependency order. http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html?highlight=sorted_tables#reflecting-all-tables-at-once On Friday, August 17, 2012 4:48:10 AM UTC+2, Greg wrote: > > Hi, > > I was naively trying to clear a db earlier in the day and I ran into this > problem: 'Cannot delete or update a parent row: a foreign key constraint > fails' > > So as anyone would do I've been searching online and through the > documentation on how to turn the foreign keys off, on delete = Cascade, > delete orphan-cascade what have you. So many hours and many stack traces > later I'd like to ask your help in this matter > > def cleanMapping(self, dbName): >> >> connection = self.dbEngines[dbName].connect() >> trans = connection.begin() >> >> for my_table in reversed(self.dbMetaData[dbName].tables.values()): >> keys= my_table.foreign_keys >> for column in my_table.columns: >> for key in keys: >>my_table = Table(my_table, self.dbMetaData[dbName], >>Column(column, Integer, >>ForeignKey(key, onupdate="CASCADE", ondelete = >> "CASCADE") >>,primary_key=True)) >>connection.execute(my_table.delete()) >> >> trans.commit() > > > So I'm fresh out of ideas; Everytime I try using this code I get > "sqlalchemy.exc.ArgumentError: Column object already assigned to Table > " > > -- 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/-/6EiRPIEPIHAJ. 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] unable to lock for update results in ResourceClosedError
Hi All, Has anyone else seen this using SQLAlchemy with MySQL? I believe something else has the table the model is mapped to locked, but this error doesn't make a lot of sense. Is this something that's been fixed in a later version? for request in session.query(SomeModel).with_lockmode('update').all(): File "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/orm/query.py", line 1579, in all return list(self) File "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/orm/query.py", line 1791, in instances fetch = cursor.fetchall() File "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", line 2498, in fetchall l = self.process_rows(self._fetchall_impl()) File "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", line 2467, in _fetchall_impl self._non_result() File "/var/buildout-eggs/SQLAlchemy-0.6.6-py2.6.egg/sqlalchemy/engine/base.py", line 2472, in _non_result "This result object does not return rows. " sqlalchemy.exc.ResourceClosedError: This result object does not return rows. It has been closed automatically. cheers, Chris -- 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.