[sqlalchemy] Re: SQL Server 2008 geography type
I am having some problems using this approach. How should I use the class STAsText in the GisElement.wkt property (example below)? My current attempts are not working... it seems that the correct statement is generated SELECT :param_1.STAsText(), but the Geography instance is not being passed as a parameter, i.e. the parameters list is empty. example script snippets @compiles_as_bound class STAsText(FunctionElement): name = 'STAsText' class GisElement(object): Represents a geometry value. @property def wkt(self): return STAsText(literal(self, Geography)).select() #... print session.scalar(r1.road_geom.wkt) Error messages 2010-01-27 12:25:16,904 INFO sqlalchemy.engine.base.Engine.0x...4270 SELECT :param_1.STAsText() 2010-01-27 12:25:16,904 INFO sqlalchemy.engine.base.Engine.0x...4270 [] Traceback (most recent call last): File .\sql_server_spatial.py, line 514, in module print session.scalar(r1.road_geom.as_wkt) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\orm\session.py, line 742, in scalar return self.execute(clause, params=params, mapper=mapper, **kw).scalar() File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\orm\session.py, line 737, in execute clause, params or {}) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1043, in execute return Connection.executors[c](self, object, multiparams, params) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1105, in _execute_clauseelement return self.__execute_context(context) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1128, in __execute_context self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1190, in _cursor_execute self._handle_dbapi_exception(e, statement, parameters, cursor, context) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1188, in _cursor_execute self.dialect.do_execute(cursor, statement, parameters, context=context) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\default.py, line 220, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', [42000] [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near ':'. (102) (SQLExecDirectW)) u'SELECT :param_1.STAsText()' [] -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@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: SQL Server 2008 geography type
On Jan 26, 2010, at 11:46 PM, dan wrote: I am having some problems using this approach. How should I use the class STAsText in the GisElement.wkt property (example below)? My current attempts are not working... it seems that the correct statement is generated SELECT :param_1.STAsText(), but the Geography instance is not being passed as a parameter, i.e. the parameters list is empty. example script snippets @compiles_as_bound class STAsText(FunctionElement): name = 'STAsText' class GisElement(object): Represents a geometry value. @property def wkt(self): return STAsText(literal(self, Geography)).select() #... print session.scalar(r1.road_geom.wkt) oh. yeah part of the recipe I gave you has something like this: %s % (someelement). call compiler.process(someelement) to get the correct bind parameter representation. Error messages 2010-01-27 12:25:16,904 INFO sqlalchemy.engine.base.Engine.0x...4270 SELECT :param_1.STAsText() 2010-01-27 12:25:16,904 INFO sqlalchemy.engine.base.Engine.0x...4270 [] Traceback (most recent call last): File .\sql_server_spatial.py, line 514, in module print session.scalar(r1.road_geom.as_wkt) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\orm\session.py, line 742, in scalar return self.execute(clause, params=params, mapper=mapper, **kw).scalar() File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\orm\session.py, line 737, in execute clause, params or {}) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1043, in execute return Connection.executors[c](self, object, multiparams, params) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1105, in _execute_clauseelement return self.__execute_context(context) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1128, in __execute_context self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1190, in _cursor_execute self._handle_dbapi_exception(e, statement, parameters, cursor, context) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\base.py, line 1188, in _cursor_execute self.dialect.do_execute(cursor, statement, parameters, context=context) File c:\python25\lib\site-packages\SQLAlchemy-0.6beta1dev-py2.5.egg \sqlalchemy\engine\default.py, line 220, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', [42000] [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near ':'. (102) (SQLExecDirectW)) u'SELECT :param_1.STAsText()' [] -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@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 sqlalch...@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: SQL Server 2008 geography type
That fixed it :) and thank you Michael for your quick response to my questions. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@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: SQL Server 2008 geography type
Thank you Michael, that really helped a lot. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@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.