Same here on pymssql.
I tried it with 'start' as the only PK, and with both 'identifier' and
'start' as PK. Both work fine.
Are you sure your in-database tabledef matches your declared schema?
I've attached a script that works here. This one has both 'identifier' and
'start' set as PK.
***---WARNING ---***:
I've added a table.drop() to the script to simplify testing and make
sure the schemas match
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
import sqlalchemy as sa
import datetime, time
from sqlalchemy.orm import sessionmaker
#dburi = 'mssql://driveulator:[EMAIL PROTECTED]/d2test'
sa_engine=sa.create_engine("mssql://xxxx:[EMAIL PROTECTED]/xxx", 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.Numeric(18), primary_key=True),
sa.Column('section', sa.VARCHAR(20)),
sa.Column("start",sa.DateTime, primary_key=True),
sa.Column("stop",sa.DateTime),
sa.Column("station", sa.VARCHAR(20)),
autoload=False)#ok
class Job(object):
def __init__(self, identifier, start, station="TCHUKI"):
self.identifier, self.start, self.station=identifier, start, station
sa.orm.mapper(Job, jobs)
try:
jobs.drop()
except:
pass
jobs.create()
j = Job(22, datetime.datetime.now())
sa_session.save(j)
sa_session.commit()
sa_session.clear()
time.sleep(1)
j1=sa_session.query(Job).all()[0]
while True:
j1.stop=datetime.datetime.now()
sa_session.save_or_update(j1)
sa_session.commit()
time.sleep(2)