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  3 root root 4.1k Nov 20 11:11 psycopg2/
drwxr-xr-x  2 root root 4.1k Nov 20 11:31 Cheetah-2.4.4-py2.6.egg-info/
drwxr-xr-x  7 root root 4.1k Nov 20 11:31 Cheetah/
drwxr-xr-x  5 root root 4.1k Nov 21 10:10 lxml/
drwxr-xr-x  2 root root 4.1k Nov 21 10:10 lxml-3.0.1-py2.6.egg-info/
drwxr-xr-x  2 root root 4.1k Nov 21 10:38 pysqlite-2.6.3-py2.6.egg-info/
drwxr-xr-x  3 root root 4.1k Nov 21 10:38 pysqlite2/
drwxr-xr-x  2 root root 4.1k Nov 21 10:51 pyspatialite-3.0.1-py2.6.egg-info/
drwxr-xr-x  3 root root 4.1k Nov 21 10:51 pyspatialite/
drwxr-xr-x  2 root root 4.1k Nov 26 13:14 SQLAlchemy-0.7.9-py2.6.egg-info/
drwxr-xr-x 10 root root 4.1k Nov 26 13:14 sqlalchemy/
drwxr-xr-x  2 root root 4.1k Nov 26 14:50 numpy-1.6.2-py2.6.egg-info/
drwxr-xr-x 18 root root 4.1k Nov 26 14:50 numpy/
drwxr-xr-x 16 root root 4.1k Nov 26 14:50 ./
                                          

-- 
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.

Reply via email to