On 9 Dic, 21:37, Michael Bayer <[EMAIL PROTECTED]> wrote:
> theyre entirely supported.  try to provide a fully working example
> illustrating the problem youre having.



Here's a small example just to simulate the problem.. The last part of
this code is there just to simulate the problem... normally i would
just keep using j and update it... and this updates the record into
the db. But if I get an instance of the Job class from a query on the
db and try to update ( or save_or_update)it the record is not updated
into the db as well..

Here the sample code:


import sqlalchemy as sa
import datetime, time
from sqlalchemy.orm import sessionmaker

sa_engine=sa.create_engine("mssql://user:[EMAIL PROTECTED]/myDB",
echo=True)
metadata = sa.MetaData(sa_engine)
Session = sessionmaker(bind=sa_engine, autoflush=True,
transactional=True)
sa_session = Session()


jobs = sa.Table('jobs', metadata,
                                                sa.Column('identifier', 
sa.databases.mssql.MSUniqueIdentifier,
primary_key=True),
                                                sa.Column('section', 
sa.databases.mssql.MSUniqueIdentifier),
                                                
sa.Column("start",sa.databases.mssql.MSDateTime_pyodbc,
primary_key=True),
                                                
sa.Column("stop",sa.databases.mssql.MSDateTime_pyodbc),
                                                sa.Column("station", 
sa.VARCHAR(20)),
                                                autoload=True)

class Job(object):
        def __init__(self, identifier, start):
                self.identifier, self.start=identifier, start

sa.orm.mapper(Job, jobs)

j = Job("TEST1", datetime.datetime.now())
sa_session.save(j)
sa_session.commit()
# The following part is here just to simluate my problem... if I keep
using j instead of getting j1 from query
# the record is updated as well....
sa_session.clear()
time.sleep(1)
j1=sa_session.query(Job).all()[0]
j1.stop=datetime.datetime.now()
sa_session.save_or_update(j1)
sa_session.commit()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to