[sqlalchemy] Re: Column metadata from mapped class

2008-07-22 Thread huy do
On Jul 22, 1:33 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 21, 2008, at 9:45 PM, huy do wrote: Because a mapped class can have an arbitary select as it's source i.e columns from any table theoretically, it would still be nice to know exactly which columns were used to map

[sqlalchemy] Re: threadlocal sessions and transactions

2008-07-19 Thread huy do
On Jul 20, 12:13 am, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 19, 2008, at 9:10 AM, Contact 42 wrote: Hi, I am using sa 0.5b2 under python 2.5. Should the following code commit myobj. engine = create_engine(appconfig.dburi, strategy='threadlocal') Session =

[sqlalchemy] Mapped class and c attribute in 0.5

2008-06-25 Thread Huy Do
Hi, I read in the 0.5 release notes that the c attribute was no longer necessary when doing queries using the mapped class, but I did not see it mentioned that the c attribute was removed all together. It's just that I've been using the c attribute in my Mapped classes to access the

[sqlalchemy] Re: Mapped class and c attribute in 0.5

2008-06-25 Thread Huy Do
Michael Bayer wrote: On Jun 25, 2008, at 10:48 AM, Huy Do wrote: Hi, I read in the 0.5 release notes that the c attribute was no longer necessary when doing queries using the mapped class, but I did not see it mentioned that the c attribute was removed all together. It's just

[sqlalchemy] Re: Adding a filter_by() clause by default.

2008-06-25 Thread Huy Do
Michael Bayer wrote: using 0.5: from sqlalchemy.orm import Query, sessionmaker class MyQuery(Query): def __new__(cls, entities, **kwargs): if hasattr(entities[0], 'deleted_at'): return Query(entities, **kwargs).filter_by(deleted_at=None) else:

[sqlalchemy] Re: threadlocal transactions, engine, and the Session

2007-11-13 Thread Huy Do
Hi Rick, I use a similar technique with a Pylons controller, but instead of engine.begin(), I use session.begin(). Then by passing around the session for all calls made by that controller, I had so much legacy SA code, that I just couldn't easily retrofit this pattern throughout the code,

[sqlalchemy] Re: threadlocal transactions, engine, and the Session

2007-11-13 Thread Huy Do
I was hoping that I could create a another session using another engine (non threadlocal), for these special cases. I have not yet run into this need yet. Just out of interest, have you run into any such use cases ? Thanks if youre using threadlocal engine, you can still say

[sqlalchemy] threadlocal transactions, engine, and the Session

2007-11-12 Thread Huy Do
Hi, I've just had a heck of a time getting transactions to behave correctly after upgrading to 0.4dev from 0.3.6, and I just wanted to make sure that I am doing things correctly. I've found that to totally control transactions myself, and get ORM sessions (i.e Session.flush()) to interact

[sqlalchemy] Re: threadlocal transactions, engine, and the Session

2007-11-12 Thread Huy Do
Michael Bayer wrote: On Nov 12, 2007, at 5:37 AM, Huy Do wrote: Hi, I've just had a heck of a time getting transactions to behave correctly after upgrading to 0.4dev from 0.3.6, and I just wanted to make sure that I am doing things correctly. I've found that to totally control

[sqlalchemy] Re: plain python objects from ORM

2007-09-25 Thread Huy Do
I think this would be a great feature to have because there are many use cases in my application (mainly displaying/processing tables) where I don't want/need the overhead of the instrumentation (and it really does add quite a bit), but would still love the excellent mapping abilities

[sqlalchemy] plain python objects from ORM

2007-09-24 Thread Huy Do
Hi, Is it possible to get SA ORM to return plain python objects (with eagerloaded relations and all) but without any attribute instrumentation (or anything else magically added by SA). Thanks, Huy --~--~-~--~~~---~--~~ You received this message because you

[sqlalchemy] Re: plain python objects from ORM

2007-09-24 Thread Huy Do
Michael Bayer wrote: On Sep 24, 2007, at 11:48 AM, Huy Do wrote: Hi, Is it possible to get SA ORM to return plain python objects (with eagerloaded relations and all) but without any attribute instrumentation (or anything else magically added by SA). not really. unless

[sqlalchemy] Re: how to leave cascade up to the database

2007-07-01 Thread Huy Do
Michael Bayer wrote: On Jun 30, 6:54 am, Huy Do [EMAIL PROTECTED] wrote: This is my problem. I have cascade delete on one of my tables, and when i try to delete a record, i get the null not allowed in foreign key error. This happens because SA is trying to update my child records when i

[sqlalchemy] Re: how to leave cascade up to the database

2007-06-30 Thread Huy Do
Michael Bayer wrote: On Jun 29, 2007, at 10:38 AM, Huy Do wrote: Hi, How do I configure my mapper/table to leave the cascade up to my database. i.e I don't want SA to auto update or delete my child objects when I delete or update my parent object. you are probably looking

[sqlalchemy] how to leave cascade up to the database

2007-06-29 Thread Huy Do
Hi, How do I configure my mapper/table to leave the cascade up to my database. i.e I don't want SA to auto update or delete my child objects when I delete or update my parent object. Thanks Huy --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: Group by? Still a problem

2007-06-27 Thread Huy Do
I think you should listen to that error message. user.id must appear in the group by or be used in an aggregate function i.e count, sum, avg etc. The other problem you are using the ORM interface. You should be using the SQL select. I'm not sure what you are trying to achieve, but your

[sqlalchemy] Re: group_by and column labels

2007-06-08 Thread Huy Do
Michael Bayer wrote: On Jun 7, 2007, at 7:17 AM, Huy Do wrote: Michael Bayer wrote: put strings into group_by: group_by = [client_code, client_name, ...] Hi Michael, Sorry I'm not sure what you are suggesting. I don't really want to retype my column names again

[sqlalchemy] Re: group_by and column labels

2007-06-08 Thread Huy Do
], group_by = [col.name http://col.name for col in group_by], On 6/7/07, *Michael Bayer* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Jun 7, 2007, at 7:17 AM, Huy Do wrote: Michael Bayer wrote: put strings into group_by: group_by = [client_code

[sqlalchemy] Re: group_by and column labels

2007-06-08 Thread Huy Do
or label_name. If i use use_labels option for the select statement, it works, because then the label names are unique across all columns. thanks Huy On 6/7/07, *Michael Bayer* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Jun 7, 2007, at 7:17 AM, Huy Do wrote: Michael Bayer

[sqlalchemy] Re: group_by and column labels

2007-06-07 Thread Huy Do
in the group by clause. Thanks, Huy On Jun 6, 2007, at 7:07 PM, Huy Do wrote: Hi, I am trying to reuse my column list in my group by clause but some of my columns use label() which is causing a sql syntax error because of the column as label in the group by clause. Is it possible

[sqlalchemy] group_by and column labels

2007-06-06 Thread Huy Do
Hi, I am trying to reuse my column list in my group by clause but some of my columns use label() which is causing a sql syntax error because of the column as label in the group by clause. Is it possible to get the group_by to only use the label side of a column . eg. (This doesn't work

[sqlalchemy] Re: Generative style on SQL-API layer

2007-06-05 Thread Huy Do
Michael Bayer wrote: I want to wake this thread up again. can we get some arguments pro/ con to converting select() to work in a generative style ? generative means either just the first, or both of these two things: - methods like append_whereclause() return a select object with which to

[sqlalchemy] Re: In Turbogears, using the same transaction for mapped objects and direct operations

2007-06-05 Thread Huy Do
Marco Mariani wrote: Sanjay ha scritto: Need help on how to do it. Being a turbogears application where db entities like metadata and session are imported rather than created by me, I am confused and could not successfully implement the pattern provided in the docs. I'm sure

[sqlalchemy] Re: Mapping existing structure of a database

2007-06-04 Thread Huy Do
Michael Bayer wrote: On Jun 4, 2007, at 6:47 PM, nathan harmston wrote: What kind of overhead is associated with using the autoload flag? What kind of overhead would be associated with this over a network? (with a remote database). Is there a way to dump the structure of a database

[sqlalchemy] Re: sqlalchemy and running custom sql.

2007-06-04 Thread Huy Do
wongobongo wrote: You mean something like this? K --- # Running a SQL Statement using SQLAlchemy from sqlalchemy import * dsn = 'mysql://root:[EMAIL PROTECTED]:3306/tester' # Create a database engine db = create_engine(dsn) # Do some SQL text(INSERT INTO insertable SELECT

[sqlalchemy] Re: query.instances and select statement

2007-05-30 Thread Huy Do
Michael Bayer wrote: On May 29, 2007, at 10:28 PM, Huy Do wrote: s = select() query = db.query(model.Invoice).options(contains_eager('client')) query = query.from_select(s) # query = query.limit(10).offset(10) rs = query.list() What I'm doing, is pretty much setting up a query

[sqlalchemy] query.instances and select statement

2007-05-29 Thread Huy Do
Hi, I am currently doing the following query: s = select() query = db.query(model.Invoice).options(contains_eager('client')) rs = query.instances(s.execute()) I was wondering if it was possible to instead of query.instances(), just attached the select to the query object, then continue to

[sqlalchemy] transaction commit problem

2007-04-19 Thread Huy Do
Hi, I am having problems getting transactions working. I am calling conn.begin() but before I call trans.commit(), something else commits for me. It is committing right after I do the job_insert.execute(). Can someone shed some light. Many Thanks Huy I have the following code

[sqlalchemy] Re: transaction commit problem

2007-04-19 Thread Huy Do
Michael Bayer wrote: On Apr 19, 2007, at 11:52 AM, Huy Do wrote: I have the following code trans = db.engine.contextual_connect().begin try: for client_id in slist.keys(): job_insert.execute( ) job_id = engine.func.currval

[sqlalchemy] Re: Opinion on correct use of Sqlalchemy

2007-04-09 Thread Huy Do
Michael Bayer wrote: On Apr 7, 2007, at 8:11 AM, HD Mail wrote: Hi, I was after some opinions on the following use of SA. 1. Is there any problems using SA in this way ? 2. Is there better ways of achieving this ? ... query =