20 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: save_or_update and c...
FromSent OnAttachments
Smoke09 Dec 2007 11:54 
Michael Bayer09 Dec 2007 12:36 
Smoke09 Dec 2007 14:26 
Michael Bayer09 Dec 2007 18:11.py
Smoke10 Dec 2007 00:39 
Rick Morrison10 Dec 2007 09:46 
Michael Bayer10 Dec 2007 10:36 
Rick Morrison10 Dec 2007 10:57 
Smoke10 Dec 2007 13:48 
Rick Morrison10 Dec 2007 15:20 
Paul Johnston10 Dec 2007 15:43 
Smoke12 Dec 2007 05:30 
Rick Morrison12 Dec 2007 08:54 
Smoke12 Dec 2007 13:56 
Smoke18 Dec 2007 15:40 
Smoke18 Dec 2007 15:43 
Michael Bayer18 Dec 2007 16:03 
Rick Morrison18 Dec 2007 16:37.py
Smoke19 Dec 2007 01:52 
Rick Morrison19 Dec 2007 06:42 
Subject:[sqlalchemy] Re: save_or_update and composit Primary Keys... MSSQL / pyodbc issue ?
From:Smoke (fabi@gmail.com)
Date:12/18/2007 03:43:42 PM
List:com.googlegroups.sqlalchemy

Sorry because i'm a bit late ( work deadlines are struggling my time! :) ). I've made some different configurations and schema definitions... and i've noticed that it never updates a row if i set the datetime field as PK ( never! even if i set it as the only PK .. ). If i set composite PKs excluding any datetime column everything works fine ( it also works if i set a datetime as PK at the database side and excluding it at the schema on sqlalchemy side.. ). Sorry about the mess with the PKs between the former examples but i was only trying to say that changing the schema results that everything works fine...

Here's a little piece of code just as an example to start playing... ( it works for me.., but if i include start as PK it "crashes")

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

sa_engine=sa.create_engine("mssql://sa:revihcra@tchuki/siaDB_BR", 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), sa.Column("stop",sa.DateTime), sa.Column("station", sa.VARCHAR(20), primary_key=True), 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)

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] j1.stop=datetime.datetime.now() sa_session.save_or_update(j1) sa_session.commit()

On 12 Dic, 17:54, "Rick Morrison" <rick@gmail.com> wrote:

Hey Fabio, would you please post a full non-working copy with the new schema and all the PKs that you want set up? There are a few too many variants in this thread to see what's going on now. Your earlier versions didn't include 'station' as a PK, but did include 'start', while this one's the opposite.