GeoAlchemy, error when querying postgis data

View: New views
4 Messages — Rating Filter:   Alert me  

GeoAlchemy, error when querying postgis data

by Jérôme Caba :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

_______________________________________________
Community mailing list
Community@...
http://lists.gispython.org/mailman/listinfo/community

Re: GeoAlchemy, error when querying postgis data

by Jérôme Caba :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jérôme Caba a écrit :

> 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
>
>
>  
I progress a little, sorry for my mistake : I wrote

print session.scalar(Communes.the_geom_bdc.wkt)

and obtain an error like this : AttributeError : Neither
'InstrumentedAttribute' object nor 'Comparator' object has an attribute
'wkt'

What did I do wrong ? thanks

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

_______________________________________________
Community mailing list
Community@...
http://lists.gispython.org/mailman/listinfo/community

Re: GeoAlchemy, error when querying postgis data

by Sanjiv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jerome,


On Thu, Oct 8, 2009 at 8:19 PM, Jérôme Caba
<jerome.caba@...> wrote:

> Jérôme Caba a écrit :
>> 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'

That should be
>> print session.scalar(my_comm.the_geom_bdc.wkt)

I request you to direct questions related to geoalchemy to the new group
http://groups.google.com/group/geoalchemy

Sanjiv

>>
>> 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
>>
>>
>>
> I progress a little, sorry for my mistake : I wrote
>
> print session.scalar(Communes.the_geom_bdc.wkt)
>
> and obtain an error like this : AttributeError : Neither
> 'InstrumentedAttribute' object nor 'Comparator' object has an attribute
> 'wkt'
>
> What did I do wrong ? thanks
>
> --
> 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@...
>
> _______________________________________________
> Community mailing list
> Community@...
> http://lists.gispython.org/mailman/listinfo/community
>
_______________________________________________
Community mailing list
Community@...
http://lists.gispython.org/mailman/listinfo/community

Re: GeoAlchemy, error when querying postgis data

by Jérôme Caba :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sanjiv Singh a écrit :

> Hi Jerome,
>  
> That should be
>  
>>> print session.scalar(my_comm.the_geom_bdc.wkt)
>>>      
>
> I request you to direct questions related to geoalchemy to the new group
> http://groups.google.com/group/geoalchemy
>
> Sanjiv
>
>  
Many many thanks Sanjiv, It's a very idiot mistake but sometimes we can
read for hours and can't see any problems :-)
I'll use now the google group


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

_______________________________________________
Community mailing list
Community@...
http://lists.gispython.org/mailman/listinfo/community