On Jul 16, 2008, at 9:43 AM, joelanman wrote:

>
> Hi,
>
> I'm a PHP/SQL coder, recently moved to Python and SQLAlchemy - really
> enjoying it so far.
>
> However, I'm having a problem as follows:
>
> I have tables for Pages and Sections (Pages have many Sections)
>
> I have working mappers for both, and sections are ordered by a
> Position column
>
> I am updating the Position column using something like the following:
>
>  conn.execute(sections.update(sections.c.id == id), position =
> new_position)
>
> If I do this, my ordering and positions are confused and not displayed
> correctly. If I stop my application and restart it, everything is
> fine.
>
> I think that I may not be dealing with my Session properly - I create
> a session in a module called db, and refer to is from my controllers.
> Do I have to close or remove this session when a controller is done in
> order to have it refresh on the next request?
>

if you execute something on a connection, the Session is not aware of  
those changes unless it's expired.   Also, if the Session is in a  
transaction, and the database you're using supports transaction  
isolation, you also may need to rollback or commit the Session's  
current transaction for it to be able to see data from other  
transactions.  One way to eliminate the latter issue is to execute  
your SQL statement using the Session's own transaction, which can be  
via Session.execute() or Session.connection().execute().

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