>
> I don’t understand.  Do you mean at the configuration level?   e.g.: 
>
> class TableB(Base): 
>     # … 
>
>    name = relationship(TableA)   # “name_id” is auto created?


Right,
So when a person is adding rows to TableB, they have a few ways of doing it.

1. If they know or lookup the actual PK of table_a.name they can add the 
row to
table_b by passing the integer value into table_b.name_id, like someone 
would
do in native SQL.

2. They can pass an object of TableA with the string value of table_a.name 
in effect
producing the lookup otherwise done manually above.

3. If the values and integrity rules permitted, they could pass
table_b.name = TableA(name='foo') without even pre populating
table_a. As an aside, this would be ideal but I have never known how to add 
the
'OR IGNORE' prefixes modifier to make that work. TableA only has a few 
values
for which many rows in TableB will reference more than once.


What I wanted to know was if it was possible to construct either a table 
definition
for TableB so that someone could simply pass in actual values of 
table_a.name
to meta columns in table_b. For example if #3 above is not possible and 
table_a
has been pre populated:

table_a:
id name
-- ----
1 foo
2 bar
3 biz

To populate table_b:

data = [
    TableB(name='foo'),
    TableB(name='bar')
    TableB(name='biz')
]
session.add_all(data)

Of course table_b has ~13 columns for which many combinations of values from
all the intermediate tables will produce unique rows...

Thanks,
jlc

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to