Guys,

I am having some difficulties in the following code. I skipped a few
lines but basically I think the logic is very clear. In the line
"u.save()" it produce the error which is pasted in part 2. I found
that the "self" object under "save" method is different than the
original one that i created by "u = BRUser()". May I ask if anyone
here will have any suggestion?

Thank you.
Riddler




Part 1
-------------------------------------------
from sqlalchemy import *
from sqlalchemy.orm import *

dbengine = create_engine('postgres://riddler:[EMAIL PROTECTED]:5432/
riddler')
metadata = MetaData()
metadata.create_all(dbengine)


class BRUser(object):
        isRecordExist = False

        @classmethod
        def save(self):
                session = create_session()
                session.save(self)
                DBObj.session.flush()
                self.isRecordExist = True


BRUser_table = Table('bruser', metadata,
        Column('user_id', Integer, primary_key=True),
        Column('username', String(50))
)

mapper(BRUser, BRUser_table, properties = {
        'userID': BRUser_table.c.user_id,
        'username': BRUser_table.c.username
})


u = BRUser()
u.username = "riddler"
u.save()

------------------------------------------
Part 2
-------------------------------------------
sqlalchemy.exceptions.InvalidRequestError: Class 'type' entity name
'None' has no mapper associated with it


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to