Oh OK, heres  the full error (also helpful):

File "/Users/classic/dev/sqlalchemy/lib/sqlalchemy/schema.py", line 71, in __call__
    raise ArgumentError("Table '%s.%s' not defined" % (schema, name))
sqlalchemy.exceptions.ArgumentError: Table 'None.People' not defined

the ForeignKey in Things should point to "people.id", not "People.id" which does not exist.

I should correct the "None" to not show up as its trying to indicate the schema name.


On Mar 25, 2006, at 10:54 PM, Jose Galvez wrote:

Sorry about that, here is the code that does not work, either with a
regular account or a supersuer account

import sqlalchemy

db =
sqlalchemy.create_engine('postgres:// user=bigeddie&passwd=rats&dbname=mystuff')

People = sqlalchemy.Table('people', db,
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
            sqlalchemy.Column('person', sqlalchemy.String(100)),
            )
Things = sqlalchemy.Table('things', db,
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
            sqlalchemy.Column('thing', sqlalchemy.String(200)),
            sqlalchemy.Column('person', sqlalchemy.Integer,
sqlalchemy.ForeignKey('People.id')),
            )



print sqlalchemy.join(Things, People).select().execute().fetchall()

Thanks for any and all help
Jose

Michael Bayer wrote:
can you please post a working test case for this. I think im about ready
to make that an auto-reply.

I made one, and it works:

from sqlalchemy import *

e = create_engine('sqlite://', echo=True)
table1 = Table('mytable', e, Column('col1', Integer)).create()
table2 = Table('mytable2', e, Column('col2', Integer,
ForeignKey('mytable.col1'))).create()

join(table1, table2).select().execute().fetchall()

result:

[2006-03-24 19:31:58,241] [engine]:
CREATE TABLE mytable(
        col1 INTEGER
)


[2006-03-24 19:31:58,243] [engine]: None
[2006-03-24 19:31:58,248] [engine]:
CREATE TABLE mytable2(
        col2 INTEGER REFERENCES mytable(col1)
)


[2006-03-24 19:31:58,249] [engine]: None
[2006-03-24 19:31:58,254] [engine]: SELECT mytable.col1, mytable2.col2
FROM mytable JOIN mytable2 ON mytable.col1 = mytable2.col2
[2006-03-24 19:31:58,255] [engine]: []


Jose Galvez wrote:

from the documentation shouldn't this work?

join(table1, table2).select().execute().fetchall()

When I jun that code I get the error None.table1 not defined

however if I run
join(table1, table2,
table1.c.id==table2.c.fk).select().execute().fetchall()

Then I get the expected results.

shouldn't the above code work if I've defined the foreign key
relationship correctly?
jose


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel? cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users









-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel? cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to