[Community] GeoAlchemy, error when querying postgis data

Jérôme Caba jerome.caba at agriculture.gouv.fr
Thu Oct 8 17:37:26 EEST 2009


Hi,

I try to use GeoAlchemy with an existant postgis db and I have one error 
when I want to query tables.
My model :
class Communes(Base):
    __tablename__ = "COMMUNES"
    id_commune = Column(Integer,primary_key=True)
    article_majuscule_commune = Column(Unicode)
    nom_majuscule_commune = Column(Unicode)
    article_minuscule_commune = Column(Unicode)
    nom_minuscule_commune = Column(Unicode)
    the_geom_rt500 = GeometryColumn(Polygon(2))
    the_geom_dgi = GeometryColumn(Polygon(2))
    the_geom_bdc = GeometryColumn(Polygon(2))

I can query all fields like this :
my_comm = session.query(Communes).filter_by(id_commune='46626').first()
print our_comm .nom_minuscule_commune
and it works

But when I want to retry the geometry (in wkt or other formats):
print session.scalar(Communes.the_geom_bdc.wkt)
I only obtain an error : "AttributeError : 'NoneType' object has no 
attribute 'scalar'

My version of sqlalchemy is 0.5.6, Geoalchemy 0.1 and python 2.5
Have I misunderstood something ? It seems like the geom format is not 
recognized...

Thank you very much


-- 
Jérôme Caba
BMSQ
Département Information Géographique
BP 12668
31326 CASTANET TOLOSAN Cedex
téléphone : 05.61.28.93.43
fax     : 05.61.28.92.82
mail : jerome.caba at agriculture.gouv.fr 




More information about the Community mailing list