13 messages in com.googlegroups.sqlalchemy[Sqlalchemy-users] Objects with just ...| From | Sent On | Attachments |
|---|---|---|
| Mike Orr | 27 Apr 2007 11:19 | |
| Kapil Thangavelu | 27 Apr 2007 11:28 | |
| Michael Bayer | 27 Apr 2007 11:34 | |
| Mike Orr | 27 Apr 2007 16:58 | |
| HD Mail | 08 May 2007 03:55 | |
| Mike Orr | 08 May 2007 17:47 | |
| Michael Bayer | 08 May 2007 21:07 | |
| Mike Orr | 09 May 2007 11:14 | |
| Mike Orr | 09 May 2007 11:45 | |
| Michael Bayer | 09 May 2007 12:13 | |
| Mike Orr | 09 May 2007 20:49 | |
| Mike Orr | 22 May 2007 15:16 | |
| Michael Bayer | 22 May 2007 18:18 |
| Subject: | [Sqlalchemy-users] Objects with just some fields![]() |
|---|---|
| From: | Mike Orr (slug...@gmail.com) |
| Date: | 04/27/2007 11:19:34 AM |
| List: | com.googlegroups.sqlalchemy |
Is it possible to make a mapper class that loads & modifies only some fields in a table rather than all the fields, yet still autoloads the fields rather than having hardcoded column types? I've been avoiding the ORM because frequenty I want to iterate every record without loading some large text fields, and to avoid 20-line SELECTS in the log which make debugging less convenient. Yet now I have a data-conversion project and have been charmed at the ability to load an object, modify and flush it, without having to do "SELECT" + "UPDATE ... WHERE".
When I brought this up previously (in a read-only context), somebody suggested mapping a Select rather than a Table. That worked but it led to "select of select" or "select of select of select", which performed considerably worse than building a query dynamically (by calling a function to to create the query and set the field list, and then calling .append_whereclause several times).
What I'd like to do is pass a list of column names to the Table constructor and have it autoload those and ignore the others. I couldn't find an argument for this. Alternatively I could autoload the table and then delete the undesired columns via a list comprehension, but it looks like that would involve modifying private attributes with possibly unintended consequences.
A few other questions and comments:
- Is there a supported way to add/remove fields from a query after it's been constructed?
- The .scalar() method of query results is incredibly useful but poorly documented. It's shown in a few examples in the manual but not explained. I added ticket #549 for it, and just now saw zzzeek's comment requesting wording explaining both that and the entire ResultProxy class, so I'll work on that.
-- Mike Orr <slug...@gmail.com>
------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
_______________________________________________ Sqlalchemy-users mailing list Sqla...@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users




