[sqlalchemy] Re: Trying to detect which class methods were added by the mapper.

2007-06-13 Thread sdobrev
are u using assign_mapper? use plain mappers to have minimal impact, u will still get plenty of new descriptors + __init__ replaced On Wednesday 13 June 2007 07:35:16 Ian Charnas wrote: Inspired by the SQLAlchemy docs, I'm writing a documentation generator in python using a combination of

[sqlalchemy] Deleting single association in many-to-many relationship

2007-06-13 Thread David Bolen
This seems like it would be a very common scenario, but it's got me stumped and feeling a bit stupid at the moment - I would appreciate anyone helping to point me in the right direction. I'm using the ORM for a many-to-many relationship, for which over time I need to be able to prune individual

[sqlalchemy] Re: Deleting single association in many-to-many relationship

2007-06-13 Thread sdobrev
what version u use? i tried your thing, that is $ python -i zz.py s = create_session() j = s.query(Job)[0] #get first del j.files[0] s.flush() and seems to work before: for a in s.query(Job): print a.name, a.files ... Job 1 [__main__.File object at 0xb78ec72c, __main__.File object at

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Roger Demetrescu
Hi Michael, Some of my coworkers had the same needs of Gaetan... And while I understand your solution, I figure out if SA could have it natively (detecting the presence of a dictionary)... Somethink like: query.get(dict(columnB='foo', columnA='bar') Lazy programmers are the best ones... :)

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Marco Mariani
Roger Demetrescu ha scritto: query.get(dict(columnB='foo', columnA='bar') Lazy programmers are the best ones... :) That's the reason lazy programmers share a superclass for all their domain objects... hint, hint :-) --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread sdobrev
Some of my coworkers had the same needs of Gaetan... And while I understand your solution, I figure out if SA could have it natively (detecting the presence of a dictionary)... Somethink like: query.get(dict(columnB='foo', columnA='bar') Lazy programmers are the best ones... :) why

[sqlalchemy] flushing and saving data using default_metadata

2007-06-13 Thread voltron
I have decided to use the global_metada to setup the tables in my app, in one of the tables, users, I setup an admin account user = User(john doe, [EMAIL PROTECTED]) how do I flush the the above object? user.flush() does not work in this context because the User object does not have the

[sqlalchemy] Re: PYTZ and SA

2007-06-13 Thread asm
Am looking in to this but have little to offer at this point. My target stack involves Turbogears, SA and PostgreSQL (with SQLite being used during development). Am not how many of the DBMS engines support datetimes that are better than naive wrt timezones which may limit the way SA has to

[sqlalchemy] postgresql rules and update

2007-06-13 Thread Antonio
hi all, I've partition a table in PostgreSQL, with rules on UPDATE, DELETE and INSERT. When I INSERT a row, ok, but when i UPDATE a row, the program raise: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1 I know that when i use a RULE the command

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Roger Demetrescu
On 6/13/07, Marco Mariani [EMAIL PROTECTED] wrote: Roger Demetrescu ha scritto: query.get(dict(columnB='foo', columnA='bar') Lazy programmers are the best ones... :) That's the reason lazy programmers share a superclass for all their domain objects... hint, hint :-) Yeaph, I

[sqlalchemy] Re: Strange InvalidRequestError when running 0.3.3 code on 0.3.8

2007-06-13 Thread Michael Bayer
youre expressing the secondary join condition on a many-to-many as shoved into the primary join. SA will be confused by that, as it requires knowledge of primary/secondary join conditions separately in order to properly construct lazy loading criterion. Group.mapper = mapper(Group, groups,

[sqlalchemy] Re: Trying to detect which class methods were added by the mapper.

2007-06-13 Thread Michael Bayer
On Jun 13, 2007, at 12:35 AM, Ian Charnas wrote: Inspired by the SQLAlchemy docs, I'm writing a documentation generator in python using a combination of epydoc (for parsing/introspection), genshi (templates), docutils (for restructured text), and pygments (syntax highlighting).. and I just

[sqlalchemy] Re: Deleting single association in many-to-many relationship

2007-06-13 Thread Michael Bayer
On Jun 13, 2007, at 7:45 AM, [EMAIL PROTECTED] wrote: the only line removed was the from .orm import * - u shouldnt use any of those internal stuff unless u know what u do. no, this will be required in 0.4, and its mentioned in some of the 0.3 docs as well. sqlalchemy.orm is not an

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread Michael Bayer
On Jun 13, 2007, at 7:54 AM, voltron wrote: I have decided to use the global_metada to setup the tables in my app, in one of the tables, users, I setup an admin account user = User(john doe, [EMAIL PROTECTED]) how do I flush the the above object? user.flush() does not work in this

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Roger Demetrescu
On 6/13/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Some of my coworkers had the same needs of Gaetan... And while I understand your solution, I figure out if SA could have it natively (detecting the presence of a dictionary)... Somethink like: query.get(dict(columnB='foo',

[sqlalchemy] Re: postgresql rules and update

2007-06-13 Thread Michael Bayer
On Jun 13, 2007, at 8:32 AM, Antonio wrote: hi all, I've partition a table in PostgreSQL, with rules on UPDATE, DELETE and INSERT. When I INSERT a row, ok, but when i UPDATE a row, the program raise: ConcurrentModificationError: Updated rowcount 0 does not match number of objects

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Michael Bayer
On Jun 13, 2007, at 8:48 AM, Roger Demetrescu wrote: But the use of this function is to ugly to my taste (I know, the give_me_pk_values_in_correct_order is too big here): customer = session.query(Customer).get (Customer.give_me_pk_values_in_correct_order(dict(columnX=3, columnY=4,

[sqlalchemy] Re: Deleting single association in many-to-many relationship

2007-06-13 Thread Michael Bayer
On Jun 13, 2007, at 6:13 AM, David Bolen wrote: * I want to remove the association between File Common and Job 1 but without affecting Job 2. If I session.delete() the fc instance directly, SA purges the file completely, including links to both jobs. I can understand SA thinking

[sqlalchemy] Re: postgresql rules and update

2007-06-13 Thread Antonio
* mercoledì 13 giugno 2007, alle 09:15, Michael Bayer wrote : SQLAlchemy's ORM relies upon cursor.rowcount after an UPDATE or DELETE to get the number of rows affected. Why exactly does your rule cause this to fail ? because is a 'INSTEAD RULE' the base table 'prev' has no row ...

[sqlalchemy] Re: Erroneous primary key of in-memory instance after session flush?

2007-06-13 Thread Michael Bayer
ticket #603 has been added for this issue. On Jun 12, 2007, at 11:48 PM, David Bolen wrote: I was converting an older table definition from using an integer primary key to a string (representation of UUID), and ran into a bit of strange behavior, where my object instance's String primary

[sqlalchemy] Re: Deleting single association in many-to-many relationship

2007-06-13 Thread David Bolen
Michael Bayer [EMAIL PROTECTED] writes: On Jun 13, 2007, at 6:13 AM, David Bolen wrote: * I want to remove the association between File Common and Job 1 but without affecting Job 2. If I session.delete() the fc instance directly, SA purges the file completely, including links to

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread sdobrev
well, if u dont want to write the same thing over and over, write one wrapping function, and publish it here. e.g. something like (pseudocode): def _get_pk_ordered( klas): table = orm.mapper.registry(klas).mapped_table #or select_table return whatever-list-of-columns def

[sqlalchemy] Re: Deleting single association in many-to-many relationship

2007-06-13 Thread sdobrev
On the second point, the complexity of the full cascade recursion with orphan detection makes sense. I suppose I'm interested in any input from anyone else as to how they are handling these sorts of operations in many-to-many cases with changing associations. As i need a history

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread Michael Bayer
On Jun 13, 2007, at 12:07 PM, voltron wrote: aha, ok, thanks, but I saw it in the docs, ist it deprecated? Then I ´m in a spot DynamicMetaData is not deprecated. but when you connect to it, its a thread-local connection. other threads that access it wont have any engine. you just

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Gaetan de Menten
On 6/13/07, Roger Demetrescu [EMAIL PROTECTED] wrote: Hi Michael, On 6/13/07, Michael Bayer [EMAIL PROTECTED] wrote: On Jun 13, 2007, at 8:48 AM, Roger Demetrescu wrote: But the use of this function is to ugly to my taste (I know, the give_me_pk_values_in_correct_order is too big

[sqlalchemy] Re: mssql reflection NoSuchTableError

2007-06-13 Thread one.person
Thanks a lot for the help guys. I got this to work by specifying the schema= argument properly. It turns out I had to specify the 'schema' argument to Table() as what MSSQL refers to as the 'Owner' of the table in enterprise manager. Still confused over the difference between schema and owner

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
Actually I thought that global_metadata was deprecated not Dynamic since you said i should not be using it. creating metadata in the base.py causes a trace, using: from sqlalchemy import * g.metadata = MetaData() D:\Projects\Pylons_projects\gameolymppaster setup-app development.ini Traceback

[sqlalchemy] Re: How to run a query in an object's session/connection

2007-06-13 Thread Roger Demetrescu
On 6/13/07, kwarg [EMAIL PROTECTED] wrote: I don't explicitly create a transaction - it's all done by TG/SA behind the scenes. Take a look at this thead (the 8th message): http://tinyurl.com/39bytt Where it says: As of TG 1.0.2+ you can now get access to the SA transaction via

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread Michael Bayer
dont use g. just get at it via myapp.base.metadata. if you want to use g, put it in app_globals.py. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
almost there: I put this in base.py from sqlalchemy import * metadata = MetaData() so anywhere I need it I just import: from gameolymp.lib.base import * I have no errors, but no databases are created or dropped, this is what I added to my websetup.py from sqlalchemy import * from

[sqlalchemy] Mapped class + querying for DISTINCT field

2007-06-13 Thread Christoph Haas
I use my assign_mapper'd classes with a lot of joy so far. But now I feel trapped. My table: records_table = Table( 'records', meta, Column('id', Integer, primary_key=True), Column('name', Unicode(80)), Column('type', Unicode(10)), Column('content', Unicode(200)),

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
I have found a solution which works, but what is the correct way Michael? I created in base.py: metadata = DynamicMetaData() then in my websetup.py : uri = conf['sqlalchemy.dburi'] engine = create_engine(uri) metadata.connect(uri) metadata.create_all() this works, but you mentioned that I

[sqlalchemy] Re: flushing and saving data using default_metadata

2007-06-13 Thread voltron
another thing, g does not work from websetup.py, which I would have liked thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com

[sqlalchemy] Cached ORM instances and eagerload queries

2007-06-13 Thread Cory Johns
I find myself in a situation where I need certain (normally lazy-loaded) properties of an ORM class to be eagerloaded for a particular query. I pass withoptions=[eagerload('property')] in to session.query(), and everything works fine. At least, it did until the query picked up a record that had

[sqlalchemy] Re: Cached ORM instances and eagerload queries

2007-06-13 Thread Michael Bayer
On Jun 13, 4:23 pm, Cory Johns [EMAIL PROTECTED] wrote: I find myself in a situation where I need certain (normally lazy-loaded) properties of an ORM class to be eagerloaded for a particular query. I pass withoptions=[eagerload('property')] in to session.query(), and everything works fine.

[sqlalchemy] Re: Using bind parameters to execute a statement

2007-06-13 Thread Michael Bayer
not really. execute_text() takes **params (and *args). heres some unit test code: conn.execute(insert into users (user_id, user_name) values (%(id)s, % (name)s), id=4, name='sally') conn.execute(insert into users (user_id, user_name) values (%(id)s, % (name)s), {'id':2, 'name':'ed'}, {'id':3,

[sqlalchemy] Re: Cached ORM instances and eagerload queries

2007-06-13 Thread Cory Johns
Excellent, thanks. Works a treat. -Original Message- From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] Behalf Of Michael Bayer Sent: Wednesday, June 13, 2007 4:51 PM To: sqlalchemy Subject: [sqlalchemy] Re: Cached ORM instances and eagerload queries ... query=