On Dec 5, 4:46 pm, "Kevin Cole" <[EMAIL PROTECTED]> wrote: > > Well, so far, Elixir, SQLAlchemy and SQLObjects have all made "easy > things hard" and "harder things impossible". In my usage, I'm failing > to see the advantage of these over: > > import pgdb > x = pgdb.connect > ... > > othe than that's not the way TurboGears seems to be geared. My SQL > needs are fairly modest, and my SQL knowledge even more so. > > The snippet I posted returns a list of tuples, which I could do more > easily with pgdb. I figured if I was going to all the trouble of > making some sort of mapping of python variable names to SQL columns, > it might be nice to be able to use them. ;-)
I definitely have a lot of sympathy with your position. Often I've found myself thinking in terms of SQL statements that get me exactly the data I need, and being frustrated when the object-relational- mapped equivalent tends to get me far more data back which I then still need to filter. I'm sure there's some object-friendly method of doing what you asked which presumably involves reading the objects into a dictionary keyed on those 3 columns or something equally foolish. :) eg. distinct_results = dict(((s.rank, s.usps, s.name), s) for s in States.select()).values() Yuk. :) Alternatively, you go through the 'raw' interface as you have, which works fine but offers no immediate benefits over connecting to the DB directly, making you ask why you bother with these layers of abstraction that just add another set of documentation you have to read. (Or find!) However, if there are times when pulling out entire records as objects is useful to you, then you may find it useful to have this choice. I'm currently using SQLObject and haven't had any problems yet, but then I'm just doing simple things for now. As long as you never use GROUP BY/DISTINCT, or aggregate functions, or non-trivial joins, SQLObject and friends work just fine. I find it surprising that there seem to be a lot of people in this situation, who seem to use databases as a thin layer over a filesystem, but there certainly are plenty of them out there. -- Ben Sizer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

