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 f
nice explanation, Simon.
2013/8/15 Simon King :
> (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
> pointing at the "id" column of the "companies" tabl
(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
pointing at the "id" column of the "companies" table.
This means that a single row in the "creators" table c
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 being
I think you may be confused about the relationship properties you have
here. As far as I can tell, a Creator can have many companies, but
each Company has only one creator, correct? So Company.creator should
only ever be an instance of Creator (or None), whereas
Creator.companies should be a list.
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, unique=Tru
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:
>
> Sor
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 should have been:
>
> existing_creator =
> DBSession(Creator).query.filter_by(creator=cre
Sorry, that should have been:
existing_creator = DBSession(Creator).query.filter_by(creator=creator).first()
On Monday, August 12, 2013 at 9:49 PM, Tim Van Steenburgh wrote:
> It's not the append that's causing the error, it's the fact that you're
> creating a new Creator() instance, which u
It's not the append that's causing the error, it's the fact that you're
creating a new Creator() instance, which ultimately results in an INSERT
statement being issued.
You want to append a Creator instance to `company.creator`, but you don't
necessarily want to make a new Creator every time y
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
In `Company.__init__()`, instead of blindly creating a new `Creator` instance,
you need to first query for an existing Creator with that name. If it exists,
append it, otherwise, create a new one and append that.
--
Tim Van Steenburgh
On Monday, August 12, 2013 at 9:26 PM, csdr...@gmail.com
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):
13 matches
Mail list logo