[sqlalchemy] Selecting across columns with func.min()

2013-08-19 Thread csdrane
Hi all, I've searched through the documentation and google on this and haven't been able to find an answer. I have the following class: class Price(Base): __tablename__ = prices id = Column(Integer, primary_key = True) company_id = Column(Integer, ForeignKey('companies.id'))

Re: [sqlalchemy] Updating a one-to-many relationship

2013-08-15 Thread csdrane
Thanks Simon -- that's what I was missing. On Thursday, August 15, 2013 5:01:31 AM UTC-4, Simon King wrote: (Sorry for any mistakes, I'm on my phone) Think of the database structure that you've got: your creators table has id, creator and company_id columns. company_id is a foreign key

Re: [sqlalchemy] Updating a one-to-many relationship

2013-08-14 Thread csdrane
Simon, your idea about putting together a script is a good one. Please see the attached. I think all these errors are related but I'm scratching my head about what the problem is. The reason I use self.creator[0] versus self.creator is for aesthetics. And, to your point about creator not

Re: [sqlalchemy] Updating a one-to-many relationship

2013-08-13 Thread csdrane
I'm afraid there are still some bugs in here that hopefully you can help with. class Creator(Base): __tablename__ = creators id = Column(Integer, primary_key = True) company_id = Column(Integer, ForeignKey('companies.id')) creator = Column(String(100), nullable=False,

Re: [sqlalchemy] Issue with session.expunge with mutually dependent tables

2013-08-12 Thread csdrane
Thanks Michael! On Sunday, August 11, 2013 4:33:20 PM UTC-4, Michael Bayer wrote: On Aug 11, 2013, at 3:06 PM, csd...@gmail.com javascript: wrote: I'm having problem with the following code which is designed to remove an object identified as malformed prior to session.commit(): if

[sqlalchemy] Updating a one-to-many relationship

2013-08-12 Thread csdrane
I have another question about a piece of code that I posted the other day. Namely, I have a one-to-many relationship between Creator and Company. A Creator can have a relationship with multiple Companies but any one Company can have a relationship with only one Creator. class Company(Base):

Re: [sqlalchemy] Updating a one-to-many relationship

2013-08-12 Thread csdrane
Sorry I don't understand what you're trying to say. If the Creator already exists, and I'm to append it again, isn't that the same as what my code is currently doing? (That is, appending in every instance.) I don't see how this wouldn't result in the same error message. And what would it mean

Re: [sqlalchemy] Updating a one-to-many relationship

2013-08-12 Thread csdrane
Very helpful, thanks Tim :) On Monday, August 12, 2013 9:53:48 PM UTC-4, Tim wrote: Ad, one more try: existing_creator = DBSession.query(Creator).filter_by(name=creator).first() -- Tim Van Steenburgh On Monday, August 12, 2013 at 9:50 PM, Tim Van Steenburgh wrote: Sorry, that

[sqlalchemy] Issue with session.expunge with mutually dependent tables

2013-08-11 Thread csdrane
I'm having problem with the following code which is designed to remove an object identified as malformed prior to session.commit(): if tickers[x] not in existing_tickers and company_names[x] not in existing_companies: company = Company(tickers[x], company_names[x], creators[x], links[x])

Re: [sqlalchemy] Creating one-to-many relationship: child class returns empty list after trying to enter data

2013-08-10 Thread csdrane
Thank you! That worked. On Saturday, August 10, 2013 5:39:31 AM UTC-4, Simon King wrote: On 10 Aug 2013, at 03:42, csd...@gmail.com javascript: wrote: This is driving me a little crazy so hopefully someone here can help. This is my first time working with sqlalchemy (v0.8). Python is

[sqlalchemy] Creating one-to-many relationship: child class returns empty list after trying to enter data

2013-08-09 Thread csdrane
This is driving me a little crazy so hopefully someone here can help. This is my first time working with sqlalchemy (v0.8). Python is v2.7.2 and MySQL is v14.14. The (heavily) summarized code is as follows: class Price(Base): __tablename__ = prices id = Column(Integer, primary_key =