typo - 81087 and 18087?
maybe run with echo=True and see what goes on?
does the testfile use same engine/.. setup as below?

On Wednesday 28 January 2009 19:21:54 Gloria W wrote:
> This is a strange problem. I'd appreciate any assistance.
> I have a class set up using the declarative_bass model, set up in
> this way:
>
>   member_profile_table = MemberProfile.__table__
>   metdata = Base.metadata
>   engine = create_engine(config.db_conn)
>   Session = sessionmaker(bind=engine)
>   session = Session()
>
> It works perfectly, as I expect, in the unit tests in the same
> file. I get the expected data from the unit test:
>
>  x.GET(81017)
>
> But in this test file, which creates in instance of my wrapper file
> in it's constructor:
>
> class Dispatch:
>   def __init__(self):
>     self.methods = ('OPTIONS','GET','HEAD','POST',
>       'PUT','DELETE','TRACE','CONNECT')
>     self.mp = MemberInfo.MemberInfo()
>
> I call the get method on the exact same query parameters.
>
>   def test(self):
>     result=self.mp.GET(18087)
>     return result.memberID
>
> A pdb trace reveals that I get a valid query object from
> SqlAlchemy. But my data set is empty.
>
> My colleague thinks it's a lazy loading issue. My model code for my
> tables appears below.
>
> Thank you in advance,
> Gloria
>
>
> import sys
> import pprint
> from sqlalchemy import *
> from sqlalchemy.ext.declarative import declarative_base
> from sqlalchemy.orm import *
>
> sys.path.append('../config')
> import config
>
> from Members import *
>
> Base = declarative_base()
> class MemberProfile(Member):
>   __tablename__ = 'member_profiles'
>
>   memberID = Column(Integer, ForeignKey('members.memberID'),
> primary_key=True)
>   SSN = Column(String)
>   DOB = Column(Date)
>   industryID = Column(Integer)
>   primarysectorID = Column(Integer)
>   address1 = Column(String)
>   address2 = Column(String)
>   city = Column(String)
>   state = Column(String)
>   zip = Column(String)
>   howhearID = Column(Integer)
>   affiliationID = Column(Integer)
>   incomeID = Column(Integer)
>   worksituationID = Column(Integer)
>   currentinsuranceID = Column(Integer)
>   genderID = Column(Integer)
>   referemail = Column(String)
>   occupation = Column(String)
>   phonehome = Column(String)
>   phonework = Column(String)
>   phonecell = Column(String)
>   phonefax = Column(String)
>   occupationID = Column(Integer)
>   occupationother = Column(String)
>   billing_address1 = Column(String)
>   billing_address2 = Column(String)
>   billing_city = Column(String)
>   billing_state = Column(String)
>   billing_zip = Column(String)
>   member = relation(Member,lazy=False,backref=backref
> ('members',order_by=memberID))
>
>   def __init__(self, memberID, SSN=None, DOB=None, industryID=None,
> primarysectorID=None,
>       address1=None, address2=None, city=None, state=None,
> zip=None, howhearID=None, affiliationID=None,
>       incomeID=None, worksituationID=None, currentinsuranceID=None,
> genderID=None, referemail=None,
>       occupation=None, phonehome=None, phonework=None,
> phonecell=None, phonefax=None, occupationID=None,
>       occupationother=None, billing_address1=None,
> billing_address2=None, billing_city=None,
>       billing_state=None, billing_zip=None, member=None):
>     self.memberID = memberID
>     self.SSN = SSN
>     self.DOB = DOB
>     self.industryID = industryID
>     self.primarysectorID = primarysectorID
>     self.address1 = address1
>     self.address2 = address2
>     self.city = city
>     self.state = state
>     self.zip = zip
>     self.howhearID = howhearID
>     self.affiliationID = affiliationID
>     self.incomeID = incomeID
>     self.worksituationID = worksituationID
>     self.currentinsuranceID = currentinsuranceID
>     self.genderID = genderID
>     self.referemail = referemail
>     self.occupation = occupation
>     self.phonehome = phonehome
>     self.phonework = phonework
>     self.phonecell = phonecell
>     self.phonefax = phonefax
>     self.occupationID = occupationID
>     self.occupationother = occupationother
>     self.billing_address1 = billing_address1
>     self.billing_address2 = billing_address2
>     self.billing_city = billing_city
>     self.billing_state = billing_state
>     self.billing_zip = billing_zip
>     self.member = member
>
>   def __repr__(self):
>     return "<MemberProfile
> ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','
>%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s'
>,'%s','%s','%s')
>
> >" % (self.memberID, self.SSN, self.DOB, self.industryID,
>
>       self.primarysectorID, self.address1, self.address2,
> self.city, self.state, self.zip, self.howhearID,
> self.affiliationID, self.incomeID, self.worksituationID,
> self.currentinsuranceID, self.genderID, self.referemail,
> self.occupation, self.phonehome, self.phonework, self.phonecell,
> self.phonefax,
> self.occupationID,
>       self.occupationother, self.billing_address1,
> self.billing_address2,
>       self.billing_city, self.billing_state, self.billing_zip)
>
> if __name__ == "__main__":
>   member_profile_table = MemberProfile.__table__
>   metdata = Base.metadata
>   engine = create_engine(config.db_conn)
>   Session = sessionmaker(bind=engine)
>   session = Session()
>
>   memberProfile = session.query(MemberProfile).filter_by
> (memberID=81017).first()
>   print "\nOriginal record:"
>   print memberProfile.__dict__
>   print memberProfile.member.__dict__
>

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