Re: [Sqlalchemy-users] engine/connection/transaction API WAS: Question about Session Object

2006-06-13 Thread Daniel Miller
Michael Bayer wrote: > ... > > now. should we just have session.connection() and have the mapper > argument be optional ? I chose to make it required to start with, based > on "explicit is better than implicit". since in most cases these days, > people have the engine accessible via the Ta

[Sqlalchemy-users] Set operations other than UNION?

2006-06-13 Thread Charles Duffy
I'm looking at writing a TurboGears-based application where I'll have cause to use not only UNION but also INTERSECT and EXCEPT. The SQLAlchemy documentation appears to indicate that only UNION is supported. Is there any chance of INTERSECT or EXCEPT showing up in future versions of SQLAlchemy?

Re: [Sqlalchemy-users] mapper order creation

2006-06-13 Thread Michael Bayer
the latest trunk uses deferred mapper compilation and solves this problem (ticket #194 in trac: http://www.sqlalchemy.org/trac/ticket/ 194 ) On Jun 13, 2006, at 5:44 PM, Randall Smith wrote: > I've got 200+ tables with lots of relationships that I'm trying to map > SQLAlchemy to. I'm writin

Re: [Sqlalchemy-users] threadlocal plugin question.

2006-06-13 Thread HD Mail
Thanks Michael, I should have read the docs a bit more carefully. I have one more question which is sort of related (but has more to do with 0.1 -> 0.2 migration) In 0.1, I used the following idiom: engine.begin() try: engine.commit() except: engine.rollback() is the equivalent in 0.2, usin

[Sqlalchemy-users] mapper order creation

2006-06-13 Thread Randall Smith
I've got 200+ tables with lots of relationships that I'm trying to map SQLAlchemy to. I'm writing a code generator to create the classes, mappings, etc. A problem that I don't see a simple solution to is writing the mapper code in the proper order. If I attempt to map one class to another th

Re: [Sqlalchemy-users] Multi-column foreign keys

2006-06-13 Thread Michael Bayer
you can define them for the purposes of querying and mapping just as separate ForeignKey objects (i.e ForeignKey(customer_id) on customer_id, ForeignKey(username) on username), and it will figure out all the appropriate join conditions connected by AND. for the purposes of having the metadat

Re: [Sqlalchemy-users] Select_by on a special mapper

2006-06-13 Thread Michael Bayer
the count(stockproducts.c.id) is internal to the subquery that you are mapping to, and its an aggregate for how many rows in stockproducts match each product id. it cant be changed by external criterion. the easiest query to map to for this is: select products.id, products.name, count(stoc

Re: [Sqlalchemy-users] Working with selectable stored procedures

2006-06-13 Thread Lele Gaifax
Michael Bayer wrote: > > On Jun 13, 2006, at 4:03 AM, Lele Gaifax wrote: > >> >> Wouldn't something like >> >>diary = FunctTable('diary(:iddip,:fromdate,:todate,:live)', ...) >> >> be a viable solution to the problem as well as a nicer approach to >> ticket #172, if at all possible? >> > > y

Re: [Sqlalchemy-users] Multiple delete and specific column select

2006-06-13 Thread Michael Bayer
you could use the table directly: t = class_mapper(MyClass).mapped_table t.delete().execute() select([t.c.col1, t.c.col2]).execute() On Jun 13, 2006, at 3:23 AM, Chetan Thapliyal wrote: > Hi > > I have two queries. > > 1. How can I delete multiple rows (may be all) of a table using > sess

Re: [Sqlalchemy-users] threadlocal plugin question.

2006-06-13 Thread Michael Bayer
yeah use the sessioncontext extension module. http://www.sqlalchemy.org/docs/plugins.myt#plugins_sessioncontext import sqlalchemy from sqlalchemy.ext.sessioncontext import SessionContext ctx = SessionContext(sqlalchemy.create_session) obj = MyObject() ctx.current.save(obj) ctx.current.flush(

Re: [Sqlalchemy-users] Working with selectable stored procedures

2006-06-13 Thread Michael Bayer
On Jun 13, 2006, at 4:03 AM, Lele Gaifax wrote: > > Wouldn't something like > >diary = FunctTable('diary(:iddip,:fromdate,:todate,:live)', ...) > > be a viable solution to the problem as well as a nicer approach to > ticket #172, if at all possible? > yes this is why I put all those notes of

Re: [Sqlalchemy-users] Question about Session Object

2006-06-13 Thread Michael Bayer
the session does bind to a single engine most easily: s = create_session(bind_to=engine) then you can in fact say: conn = session.connection(None) now. should we just have session.connection() and have the mapper argument be optional ? I chose to make it required to start wi

[Sqlalchemy-users] Multi-column foreign keys

2006-06-13 Thread Arnar Birgisson
Hi there.. Is is it possible to describe multi-column foreign keys with SA metadata? I.e. create table customers ( customer_id string, primary key (customer_id) ) create table users ( customer_id string, username string, primary key (customer_id, username), foreign key (customer_id) references

[Sqlalchemy-users] threadlocal plugin question.

2006-06-13 Thread HD Mail
Hi, Is it possible to get the functionality of the threadlocal plugin (i.e objectstore/default thread local session), but not have all my mapped classes automatically added to the objectstore when i instantiate them ? I am willing to call "save" on objects I want to save. Many Thanks, Huy _

[Sqlalchemy-users] Multiple delete and specific column select

2006-06-13 Thread Chetan Thapliyal
Hi I have two queries. 1. How can I delete multiple rows (may be all) of a table using session query object based on a specific python class that is binded to a table using mapper? 2. Is there any way of selecting only specific columns of a table using the same session query object as above.

Re: [Sqlalchemy-users] Working with selectable stored procedures

2006-06-13 Thread Lele Gaifax
Michael Bayer wrote: > ideally you should be able to say: > > func.diary(iddip, fromd, tod, True).select() > > however this will produce "SELECT diary(?, ?, ?, ?)" which isnt going to > work since its naming the function as a column. Function objects in SA > currently are designed to follo