[sqlalchemy] Re: Could someone look over this diff for update to the version recipe.

2009-08-25 Thread Michael Bayer
as long as all the existing tests pass feel free to add it in ! thanks On Aug 25, 2009, at 7:54 PM, kindly wrote: > > Hello, > > The version recipe on the wiki will version if the object is dirty, > but I thought it would be more useful if it did it only when there was > an actual change. > >

[sqlalchemy] Could someone look over this diff for update to the version recipe.

2009-08-25 Thread kindly
Hello, The version recipe on the wiki will version if the object is dirty, but I thought it would be more useful if it did it only when there was an actual change. The diff is below, added a test too, and I would be happy to upload it after someone looks over it? The recipe is at http://www.sq

[sqlalchemy] Most elegant SqlSoup solution cope with legacy client db tables without primary keys?

2009-08-25 Thread Xavian
I have a client I'm doing new product integration work that requires some complicated joins against legacy db tables. Most of their tables all have primary keys which SqlSoup can cope with readily. There are a few, however, that lack a primary key. A table I need to process is called itemattribut

[sqlalchemy] Re: Problem:maximum recursion depth exceeded - Ticket #1081

2009-08-25 Thread Michael Bayer
Marin wrote: > > On Aug 18, 11:40 pm, Philip Jenvey wrote: >> There's a README.unittests that should tell you all you need to know. >> >> Basically you need a test database, possibly a 'test_schema' depending   >> on the db (see the bottom of the doc), then run: >> >> nosetests -v --dburi=some://

[sqlalchemy] Re: making an instance read-only

2009-08-25 Thread Gregg Lind
Based on Michael Bayer's hint, I built this instance-level changeable object. It used Declarative, which actually makes it a bit tougher, but this code should work for pypo's also. It's hackish in that it just monkeys with __setattr__, but it's clear(ish) what's happening. ---

[sqlalchemy] Re: Problem:maximum recursion depth exceeded - Ticket #1081

2009-08-25 Thread Marin
On Aug 18, 11:40 pm, Philip Jenvey wrote: > There's a README.unittests that should tell you all you need to know. > > Basically you need a test database, possibly a 'test_schema' depending   > on the db (see the bottom of the doc), then run: > > nosetests -v --dburi=some://uri/db I run the tests

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Martijn Faassen
Hey, Michael Bayer wrote: > at the very least if you could > add a trac ticket that's targeted at 0.5.6 with "high" priority it can be > the next thing I look at. I've added ticket 1519: http://www.sqlalchemy.org/trac/ticket/1519 I may look into adding the tests later this week myself, but at

[sqlalchemy] Re: making an instance read-only

2009-08-25 Thread Mike Bernson
There is a way to catch every modify event at the time it is being modify. This is some code I use to send events when attribute are modified. There is an attribute that you can put on the model class __sa_instrumentation_manager__ = SetListener and then here is code to handle modify events: c

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Michael Bayer
Martijn Faassen wrote: > > Hey Michael, > > Cool that you managed to reproduce the issue. > > Michael Bayer wrote: > >> and a potential fix is this: >> >> Index: lib/sqlalchemy/orm/session.py >> === >> --- lib/sqlalchemy/orm/session.p

[sqlalchemy] Re: Relation with distinct

2009-08-25 Thread Michael Bayer
Seth wrote: > > Michael, > > Thank you for your quick reply, however I must apologize as I'm a bit > of a SQLAlchemy newbie. > > In the app I'm using the tables are setup using DeclarativeBase, so > the mapper() function is confusing me with its need for a class to be > defined as well as a table_

[sqlalchemy] Re: Schema names, SQLite and MS Sql

2009-08-25 Thread markscottwright
That won't quite work for me - I'm not really 'building up' the metadata, I'm introspecting it using SqlSoup so the schema name gets put there automatically. I had hoped to do this automatically, but I really only have to copy the schema once, so what I did is just "print repr(table._table)" for

[sqlalchemy] Re: making an instance read-only

2009-08-25 Thread Martijn Faassen
phrrn...@googlemail.com wrote: > You are correct: the code-snippet will cause an exception to be thrown > when SA attempts to flush any changes. However, the connection > callable is called *per-instance* and it is supposed to return the > connection to use to perform the flush. Inside the callabl

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Martijn Faassen
Hey Michael, Cool that you managed to reproduce the issue. Michael Bayer wrote: > and a potential fix is this: > > Index: lib/sqlalchemy/orm/session.py > === > --- lib/sqlalchemy/orm/session.py (revision 6289) > +++ lib/sqlalc

[sqlalchemy] Re: Relation with distinct

2009-08-25 Thread Seth
Michael, Thank you for your quick reply, however I must apologize as I'm a bit of a SQLAlchemy newbie. In the app I'm using the tables are setup using DeclarativeBase, so the mapper() function is confusing me with its need for a class to be defined as well as a table_name = Table(); and then usi

[sqlalchemy] Re: Relation with distinct

2009-08-25 Thread Michael Bayer
Seth wrote: > > I'm trying to set up a relation from one table to another that will > give me a count of the unique user_id's that have posted a comment to > a post. > > For example: I've set up "post" as the parent table, and "comments" as > the child table (with post_id, user_id, comment_body, e

[sqlalchemy] Relation with distinct

2009-08-25 Thread Seth
I'm trying to set up a relation from one table to another that will give me a count of the unique user_id's that have posted a comment to a post. For example: I've set up "post" as the parent table, and "comments" as the child table (with post_id, user_id, comment_body, etc). What I want to be ab

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Michael Bayer
Martijn Faassen wrote: > > Hi there, > > I'm looking at the remove() method in > sqlalchemy.orm.identify.WeakInstanceDict, as this is where the assertion > error is raised. > > In the 'self' dictionary there is indeed an > sqlalchemy.orm.state.InstanceState object with under the key (it's the > on

[sqlalchemy] Re: Schema names, SQLite and MS Sql

2009-08-25 Thread Michael Bayer
look into buildng your metadata first with no schema, then copying it to the MSSQL schema using tometadata(m, schema='myschema'). the schema name change should be propagated into foreign keys. unfortunately it doesn't seem to support un-setting the schema name at the moment so that's why the r

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Michael Bayer
Martijn Faassen wrote: > > Michael Bayer wrote: >> 1. whats this ? >> >> File "bin/devpython", line 25, in ? >> execfile(sys.argv[0]) > > That's a buildout-generated Python script that just controls what's on > the python path. It effectively behaves like the Python interpreter. > I've never

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Martijn Faassen
Hi there, I'm looking at the remove() method in sqlalchemy.orm.identify.WeakInstanceDict, as this is where the assertion error is raised. In the 'self' dictionary there is indeed an sqlalchemy.orm.state.InstanceState object with under the key (it's the only entry in the dictionary), but it's

[sqlalchemy] Re: making an instance read-only

2009-08-25 Thread phrrn...@googlemail.com
You are correct: the code-snippet will cause an exception to be thrown when SA attempts to flush any changes. However, the connection callable is called *per-instance* and it is supposed to return the connection to use to perform the flush. Inside the callable, you can peek at the mapper and/or th

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Martijn Faassen
Michael Bayer wrote: > 1. whats this ? > > File "bin/devpython", line 25, in ? > execfile(sys.argv[0]) That's a buildout-generated Python script that just controls what's on the python path. It effectively behaves like the Python interpreter. I've never had any problems with it before in

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Michael Bayer
So I moved it onto my linux box, since we have issues that show up differently on osx/linux due to dictionary ordering - but the program still runs fine. So I've run it on python 2.6 and 2.4, OSX and linux. It doesn't even seem like it could be GC related since you are holding a strong referen

[sqlalchemy] Schema names, SQLite and MS Sql

2009-08-25 Thread markscottwright
I'm trying to use SQLAlchemy to move a database from SQLServer to SQLite (so I can play with it at home on my linux box). I've gotten surprisingly far - I'm very impressed with SQLAlchemy! But I'm facing a problem with MS Sql's 'schema names' - which other dbs refer to a 'owners', I think. Sadl

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Martijn Faassen
Hey, I now also tested the program with sqlite3 3.6.10: same problem. pysqlite2.5.5 is in use. Regards, Martijn --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send ema

[sqlalchemy] Re: composite primary key problem

2009-08-25 Thread Martijn Faassen
Hey, Michael Bayer wrote: > the program works for me, I get: That's interesting. I've tested the script with Python 2.4, Python 2.5, and Python 2.6, with SQLAlchemy 0.5.5 and trunk. sqlite version is 3.4.2. I get the assertion error each time. The output I get when echo is True (on SA trunk/P

[sqlalchemy] Re: making an instance read-only

2009-08-25 Thread Martijn Faassen
Hey, phrrn...@googlemail.com wrote: > I implemented a very crude flush/commit-time version of this today > that disables all modifications. Michael suggested the use of > connection_callable to provide fine-grained control of which engine to > use for modifications. I haven't gone through all the

[sqlalchemy] Re: Tracking Last Update timestamp for models

2009-08-25 Thread King Simon-NFHD78
> -Original Message- > From: sqlalchemy@googlegroups.com > [mailto:sqlalch...@googlegroups.com] On Behalf Of Stephen Hansen > Sent: 25 August 2009 07:34 > To: sqlalchemy@googlegroups.com > Subject: [sqlalchemy] Tracking Last Update timestamp for models > > Hi all. > > I'm working on co