While primary_key is specified twice, once for each column, there is only
ONE primary key which is a composite.
You need to use ForeignKeyConstraint at the Table level to specify a
composite foreign key.
You need to provide two lists, the local table columns, and the
corresponding foreign
I don't understand your model. Can you have multiple rows in the
Exchange table which all have the same value for Exchange.exchange?
If so, and if you want PhoneNumber to be able to point to a single one
of those rows, then it needs 2 columns to do that (one to point to
Exchange.exchange and one
Hi Lloyd,
Thank you! I believe this is what I was trying to figure out, although I am
having further issues now. Here's a recent pastie with my improved models,
along with the errors I'm now having, http://pastie.org/6417080
What I've done (as you can probably see) is I've used the
You have to put your ForeignKeyConstraint in the __table_args__ for the
PhoneNumber class - see
http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#table-configuration
for details. Something like:
class PhoneNumber(db.Model):
__tablename__ = 'phonenumbers'
Hi Simon,
Ok cool. So, I updated that, but now I'm getting the following error:
sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column
'phonenumbers.exchange_exchange' could not find table 'exchange' with which
to generate a foreign key to target column 'exchange'
It looks
According to the pastie log, your table is called exchanges, not exchange,
so the target columns should be called exchanges.exchange and
exchanges.area_code_pk.
Simon
On 8 Mar 2013, at 00:27, Randall Degges rdeg...@gmail.com wrote:
Hi Simon,
Ok cool. So, I updated that, but now I'm
Simon,
Thanks man! This works perfectly, can't believe I didn't see that.
This was actually a really frustrating experience, you guys have been
extremely helpful. Thank you all so much!
Best,
-Randall
On Thu, Mar 7, 2013 at 5:15 PM, Simon King si...@simonking.org.uk wrote:
According to the
Hi all,
I'm having a lot of trouble figuring out how to properly build my
ForeignKey column for a table I'm defining. I've outlined my models here:
http://pastie.org/6407419# (and put a comment next to the problematic line
in my PhoneNumber model).
Here's what's happening:
My Exchange table
a database table can only have one primary key (hence primary), but that key
can contain more than one column (a composite primary key).
the model you have here is a little unclear, did you mean for the primary key
of Exchange to be exchange , and the primary key of PhoneNumber to be the
Hi Mike,
Sorry about that, I actually had a typo there. I've got a correct code
sample available here
http://stackoverflow.com/questions/15260842/how-can-i-build-a-foreignkey-to-a-table-which-has-multiple-primary-keys
(just
posted it).
Thank you,
-Randall
On Wed, Mar 6, 2013 at 5:54 PM,
10 matches
Mail list logo