import sqlalchemy import sqlalchemy orm sqlalchemy create_engine postg

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
>>> import sqlalchemy
>>> import sqlalchemy.orm
>>> e = sqlalchemy.create_engine('postgres://osm:osm@127.0.0.1:5432/gis')
>>> s = sqlalchemy.orm.scoped_session(sqlalchemy.orm.sessionmaker(autoflush=False, autocommit=True, bind=e))
>>> s.execute("SELECT ST_AsText(transform(GeometryFromText('MULTIPOINT(:bbox)', 4326), 900913))", dict(bbox='1 1, 2 2'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/orm/scoping.py", line 121, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/orm/session.py", line 755, in execute
clause, params or {})
File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 824, in execute
return Connection.executors[c](self, object, multiparams, params)
File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 874, in _execute_clauseelement
return self.__execute_context(context)
File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 896, in __execute_context
self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context)
File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 950, in _cursor_execute
self._handle_dbapi_exception(e, statement, parameters, cursor, context)
File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.2-py2.6.egg/sqlalchemy/engine/base.py", line 931, in _handle_dbapi_exception
raise exc.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at or near "1"
LINE 1: ...T_AsText(transform(GeometryFromText('MULTIPOINT(E'1 1, 2 2')...
^
"SELECT ST_AsText(transform(GeometryFromText('MULTIPOINT(%(bbox)s)', 4326), 900913))" {'bbox': '1 1, 2 2'}