I have some sqlite tables such as:

CREATE TABLE table_a (
id INTEGER NOT NULL,
table_b_id INTEGER NOT NULL,
name VARCHAR,
PRIMARY KEY (id),
FOREIGN KEY(table_b_id) REFERENCES table_b (id) ON DELETE CASCADE
);

CREATE TABLE table_b (
id INTEGER NOT NULL,
table_c_id INTEGER NOT NULL,
name VARCHAR,
PRIMARY KEY (id),
FOREIGN KEY(table_c_id) REFERENCES table_c (id) ON DELETE CASCADE
);

CREATE TABLE table_c (
id INTEGER NOT NULL,
name VARCHAR,
PRIMARY KEY (id)
);

I was hoping to leverage the natural joins I thought might exist, but a
query such as:
  query = session.query(table_a).join(table_b).join(table_c)
doesn't return the join() tables for each record.

Something like does:
query = session.query(table_a, table_b, table_c).\
    join(table_b, table_b.id == table_a.table_b_id).\
    join(table_c, table_c.id == table_b.table_c_id).\
    all()

I am pretty sure I am missing something, what requirements does the first
query have
that I am missing?

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/groups/opt_out.

Reply via email to