[sqlalchemy] circular model definitions

2008-07-09 Thread Matt Haggard
I'm stumped... Setup: (Problem statement near the bottom) In my Pylons app, I have three separate models: Customer, TPPAnswer, SAQ TPPAnswer is many-to-one Customer SAQ is many-to-one Customer Both have backreferences (so saq.customer and customer.saqs) Currently, I have them defined in

[sqlalchemy] ProgrammingError: (ProgrammingError) current transaction is aborted, commands ignored until end of transaction block

2008-06-27 Thread Matt Haggard
I'm getting a ProgrammingError (I've pasted the last part of the traceback at the bottom of the page). The error comes from my first heavy-AJAX page in Pylons (postgres backend). If I cause too many AJAX requests at a time, or even after doing 3 non-overlapping AJAX requests, I get the error.

[sqlalchemy] Re: ProgrammingError: (ProgrammingError) current transaction is aborted, commands ignored until end of transaction block

2008-06-27 Thread Matt Haggard
, Matt Haggard wrote: I'm getting a ProgrammingError (I've pasted the last part of the traceback at the bottom of the page). The error comes from my first heavy-AJAX page in Pylons (postgres backend).  If I cause too many AJAX requests at a time, or even after doing 3 non-overlapping

[sqlalchemy] Re: ProgrammingError: (ProgrammingError) current transaction is aborted, commands ignored until end of transaction block

2008-06-27 Thread Matt Haggard
: On Jun 27, 2008, at 5:03 PM, Matt Haggard wrote: INSERT or UPDATE?  I don't do any inserts with this code... only changing what's already there. Is an integrity constraint a PG thing, or SQLAlchemy model thing? its a PG thing.  Other things can likely cause PG to get into this   state

[sqlalchemy] Models split across files

2008-06-24 Thread Matt Haggard
In my various models, I recently noticed that I have been reusing my customer table as it relates to many other models. I've been making CustomerPart objects in each of the model files and retyping the table schema and object (only including the pieces I need for that particular case) Now I'd

[sqlalchemy] Re: Triple Join Table

2008-06-17 Thread Matt Haggard
. On Jun 16, 5:11 pm, Matt Haggard [EMAIL PROTECTED] wrote: I've got a triple join table (joining three things together) and I'm really struggling to get it to work as I intend.  I've pasted the full model at the bottom.  I've struggled with this off and on for months now... I don't really

[sqlalchemy] appending an object through an 2-level association table

2008-05-07 Thread Matt Haggard
I'm trying to figure out how to add objects through the ORM. (My schema and mappings are below.) In the shell, I can do the following: newQ = Question() # ... set the attributes of newQ mytype = session.query(QType).first() mytype.my_sections # correctly gives all the sections that belong to

[sqlalchemy] Re: Goofy Association Table

2008-05-06 Thread Matt Haggard
are all the Questions (ignoring the Sections; grouping by Questions)? my_type = Type() all_questions = my_type.questions ?? I appreciate the help, Matt On May 5, 3:32 pm, Michael Bayer [EMAIL PROTECTED] wrote: On May 5, 2008, at 5:11 PM, Matt Haggard wrote: I've got a kind of goofy

[sqlalchemy] Goofy Association Table

2008-05-05 Thread Matt Haggard
I've got a kind of goofy schema, and I'm trying to map it. I've got Questionnaire types, Sections and Questions all joined in a single association table: join_table : type_id | section_id | question_id questions_table : id | question_text sections_table : id | section_name types_table : id |

[sqlalchemy] Handling unique constraints

2008-01-04 Thread Matt Haggard
the db? 2) How do I let the user know which value caused the record not to update? What information does SQLAlchemy provide back that I can use to say: You're number must be unique... and such-and-such must be greater than 0, etc..? Thanks, Matt Haggard

[sqlalchemy] Re: Sum with Grouping

2007-11-21 Thread Matt Haggard
Oh, okay. Thanks you. On Nov 20, 5:23 pm, Michael Bayer [EMAIL PROTECTED] wrote: the aggregate methods on Query, such as apply_sum(), apply_avg(), etc., are not in such great shape right now...they've been neglected and in fact aren't even working correctly with GROUP BY, etc...I've added

[sqlalchemy] Re: Sum with Grouping

2007-11-21 Thread Matt Haggard
thank you for the response. I have a few more followup questions (I am really a newbie to this...) : 1. Where does engine come from? Is there anyway to do what you've suggested with Session? If it helps, I'm using this with pylons and am trying to get stuff working in the controller of my app.

[sqlalchemy] Sum with Grouping

2007-11-20 Thread Matt Haggard
I'm very new to sqlalchemy and I'm still trying to wrap my head around how it works. I have a table with columns: type, amount. I want to sum the amounts grouped by type. In SQL I would write: SELECT sum(amount), type from purchases group by type; How do I do this with SQLAlchemy? This is