Hello,
 I'm using Elixir with SQLAlchemy, and I'm having trouble with
querying a single column in the database. Here is my class and the
error that it throws up when I access a column:

import elixir
from sqlalchemy import orm, create_engine, MetaData
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.types import *

class dateTest(elixir.Entity):
    UserID      = elixir.Field(elixir.Integer, primary_key=True,
autoincrement=True)
    Date1   = elixir.Field(elixir.TIMESTAMP(timezone=True))
    Date2   = elixir.Field(elixir.DateTime)


    def __init__(self, uId = None, date1 = None, date2 = None):
        self.UserID = uId
            self.Date1  = date1
            self.Date2  = date2

    def __repr__(self):
        return '<%s %s %s>' %(repr(self.UserID), self.Date1,
self.Date2)


>>> elixir.session.query(dateTest.Date1).all()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "d:\python24\lib\site-packages\sqlalchemy-0.4.6-py2.4.egg
\sqlalchemy\orm\scoping.py", line 98
, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "d:\python24\lib\site-packages\sqlalchemy-0.4.6-py2.4.egg
\sqlalchemy\orm\session.py", line 76
0, in query
    q = self._query_cls(mapper_or_class, self, **kwargs)
  File "d:\python24\lib\site-packages\sqlalchemy-0.4.6-py2.4.egg
\sqlalchemy\orm\query.py", line 68,
in __init__
    self.__init_mapper(_class_to_mapper(class_or_mapper,
entity_name=entity_name))
  File "d:\python24\lib\site-packages\sqlalchemy-0.4.6-py2.4.egg
\sqlalchemy\orm\util.py", line 399,
in _class_to_mapper
    return class_or_mapper.compile()
AttributeError: 'InstrumentedAttribute' object has no attribute
'compile'
>>>

When I query for the entire object, I can get it without any problems:
>>> elixir.session.query(dateTest).all()
2008-07-16 16:06:12,010 INFO sqlalchemy.engine.base.Engine.0x..10
SELECT datetest_datetest."UserID"
AS "datetest_datetest_UserID", datetest_datetest."Date1" AS
"datetest_datetest_Date1", datetest_date
test."Date2" AS "datetest_datetest_Date2"
FROM datetest_datetest ORDER BY datetest_datetest.oid
2008-07-16 16:06:12,010 INFO sqlalchemy.engine.base.Engine.0x..10 []
[<1 2008-07-16 14:17:22 None>, <2 2008-07-16 14:19:24 2008-07-16
14:19:24>, <3 2008-07-16 14:19:27 2
008-07-16 14:19:27>, <4 2008-07-16 14:19:29 2008-07-16 14:19:29>, <5
2008-07-16 15:03:04 2008-07-16
15:03:04>, <6 2008-07-16 15:03:07 2008-07-16 15:03:07>, <7 2008/07/16
15:03:09.390 GMT-7 2008/07/16
15:03:09.390 GMT-7>, <8 2008/07/16 15:03:11.315 GMT-7 2008/07/16
15:03:11.315 GMT-7>, <100 2008-07-1
6 00:00:00 2008-07-17 15:07:10>, <101 2008/07/16 16:04:28.346 GMT-7
2008/07/16 16:04:28.346 GMT-7>,
<102 2008/07/16 16:04:32.681 GMT-7 2008/07/16 16:04:32.681 GMT-7>]
>>>

Any ideas what could be wrong with a query to get a single column from
the database?

Your help will be appreciated.
thanks,
Venkatesh.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to