Massimo

The problem with the above example is that, tho' it works fine first
time thru', subsequent executions (for me at least) result in

"'users' referenced before assignment"

I believe that this is because any variable defined in db.py (e.g.
users) is global but is only assigned to if it is a table and being
created (and perhaps modified?)

As Table contains db.define_table, the controller code should read
"db.users.insert..." and db.dogs.owner..."

Bill

On Nov 17, 4:36 am, mdipierro <[EMAIL PROTECTED]> wrote:
> ** This is incomplete and to be considered a proof of concept **
>
> 1) download
>
> http://groups.google.com/group/web2py/web/sqlalchemy.py
>
> 2) import it in your app and try the following model:
>
>     db=SQLDB()
>     metadata=MetaData(db)
>
>     users = Table('users', metadata,
>        Column('id', Integer),
>        Column('name', String(40)),
>        Column('age', Integer),
>        Column('password', String),
>        Column('blob1',Binary),
>     )
>
>     dogs = Table('dogs', metadata,
>        Column('id', Integer),
>        Column('name', String(40)),
>        Column('owner', ForeignKey('users.id')),
>     )
>
>     print users.fields
>     print dogs.fields
>
> 3) click on [database administration] to see the generated interface.
>
> As in the Django cases, the above code defines tables 'users' and
> 'dogs'. They are web2py tables so you can do:
>
> id=users.insert(name='Test')
> dogs.insert(name='Snoopy',owner=id)
> for row in db(dogs.owner==users.id).select(): print
> row.dogs.name,row.users.name
>
> Massimo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to