On Feb 4, 8:30 am, Mike Driscoll <[email protected]> wrote:
> On Feb 4, 4:24 am, "King Simon-NFHD78" <[email protected]>
> wrote:
>
>
>
> > > -----Original Message-----
> > > From: [email protected]
> > > [mailto:[email protected]] On Behalf Of Mike Driscoll
> > > Sent: 04 February 2010 03:34
> > > To: sqlalchemy
> > > Subject: [sqlalchemy] Another tutorial!
>
> > > Hi,
>
> > > I just finished up a tutorial series on SqlAlchemy that I thought I'd
> > > share:
>
> > >http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-s
> > > tep-sqlalchemy-tutorial-part-1-of-2/
> > >http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-s
> > > tep-sqlalchemy-tutorial-part-2-of-2/
>
> > > Hopefully it's made well enough that people can follow the tutorial
> > > easily. Let me know if I made any serious blunders.
>
> > > Thanks,
>
> > > Mike
>
> > Hi Mike,
>
> > Not a serious blunder, but I think there may be a small mistake in part
> > 2, where you describe updating an email address:
>
> > # change the first address
> > prof.addresses[0] = Address("[email protected]")
>
> > I don't think this is going to update the '[email protected]' row in the
> > database to say '[email protected]'. Instead, it is going to disconnect
> > that row from the user by setting the user_id to NULL, and add a new row
> > with the new address. (This may be what you intended, but I don't think
> > it's clear from the description).
>
> > I would have thought that you'd actually want to write this:
>
> > # change the first address
> > prof.addresses[0].email_address = "[email protected]"
>
> > Hope that helps,
>
> > Simon
>
> I was testing this in IDLE and it seemed to work when I did
> prof.addresses to check it. If the user gets set to NULL, wouldn't
> prof.addresses only show one entry? I'll check it out and make sure.
> If I messed it up, I'll get it fixed. Thanks for the bug report!
>
> - Mike
I just ran through that section again using the Python interpreter and
after changing the address like this:
prof.addresses[0] = Address("[email protected]")
I then used the following (per the official tutorial):
>>> prof.addresses[0].user
<User('Prof','Prof. Xavier', 'fudge')>
So my method appears to work. I tried your method too:
>>> prof.addresses[0].email_address = "[email protected]"
>>> prof.addresses[0].user
<User('Prof','Prof. Xavier', 'fudge')>
>>>
That appears to give the same result. Let me know if I am
misunderstanding something basic here.
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
PyCon 2010 Atlanta Feb 19-21 http://us.pycon.org/
--
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.