20 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: save_or_update and c...| From | Sent On | Attachments |
|---|---|---|
| Smoke | 09 Dec 2007 11:54 | |
| Michael Bayer | 09 Dec 2007 12:36 | |
| Smoke | 09 Dec 2007 14:26 | |
| Michael Bayer | 09 Dec 2007 18:11 | .py |
| Smoke | 10 Dec 2007 00:39 | |
| Rick Morrison | 10 Dec 2007 09:46 | |
| Michael Bayer | 10 Dec 2007 10:36 | |
| Rick Morrison | 10 Dec 2007 10:57 | |
| Smoke | 10 Dec 2007 13:48 | |
| Rick Morrison | 10 Dec 2007 15:20 | |
| Paul Johnston | 10 Dec 2007 15:43 | |
| Smoke | 12 Dec 2007 05:30 | |
| Rick Morrison | 12 Dec 2007 08:54 | |
| Smoke | 12 Dec 2007 13:56 | |
| Smoke | 18 Dec 2007 15:40 | |
| Smoke | 18 Dec 2007 15:43 | |
| Michael Bayer | 18 Dec 2007 16:03 | |
| Rick Morrison | 18 Dec 2007 16:37 | .py |
| Smoke | 19 Dec 2007 01:52 | |
| Rick Morrison | 19 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqla...@googlegroups.com
To unsubscribe from this group, send email to
sqla...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---





.py