On Oct 28, 2008, at 9:32 AM, writeson wrote:
> > Hi everyone, > > I'm struggling to try and use SqlAlchemy (0.5rc2) with a project I'm > working on. The database part isn't very hard, it's just a flat table, > but I keep running into problems with SA throwing exceptions. The SA > documentation is good, but as of yet I haven't gotten the "ah ha" > moment of how to put it all together. What I need to see is a simple, > complete application example that would show me how the pieces fit > together as a whole. In particular I'm looking for things like this: > > 1) When and how to update the database when modifying a Class > instance. the ORM tutorial steps through this process fairly methodically, and touches upon the full lifecycle of an object. Also a good read of the session chapter explains exactly what the Session is doing. 0.5's default session configuration follows a model whereby you generally don't have to deal with anything except add/ delete/commit. > > 2) Can database object instances be maintained in a Python list, or > should they be handled one at a time? there's no restriction on how mapped instances are structured or persisted. > > 3) Does deleting a database object instance (del obj) delete the > row from the database, or should session.delete(obj) be called first > and then del obj? del obj just dereferences the variable named "obj" from the local namespace in the Python process. If no further references remain on the object, it will be garbage collected, including from SQLA's Session. This does not communicate a database delete operation to the session. SQLAlchemy records an object for pending deletion using Session.delete(obj). If you issue this call, the Session temporarily creates a strong reference to the object's mapped information so that it stays in scope, at least within the Session, until the transaction commits. > 4) Is it possible to apply a Python __cmp__() method to a list of > database objects, or should SA order by operations be used instead? either approach is feasable depending on the situation.... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---