Thank you!

Mengu on irc helped make me all smart as well.

For completeness sakes in case someone else gets as dumb as me, a very
very quick reference, based on what I've learned today.

#make the DB.
db.define_table('tablename',Field('fieldname','type',options)


INSERT:
        db.TABLENAME.insert(field=value,field=value)

UPDATE:
        get object from query
        object.update_record(field=value,field=value)

        you *can* do this, but well....
        db.TABLENAME.id[id] = dict(field=value,field=value)


DELETE:
        db(db.table.id == 5).delete()

QUERY:
        db(WHERE CLAUSE).select(WHAT TO GET)

get first entry:
   object = db(where).select().first()



On Mar 4, 7:10 pm, mdipierro <[email protected]> wrote:
> It is not
>
> >>> db().select(db.test.id>0)
>
> but
>
> >>> db(db.test.id>0).select()
>
> db(condition).select(*fields,orderby=..,groupby=...,limitby=...,cache=...,distinct=...)
>
> On Mar 4, 5:26 pm, compassiontara <[email protected]> wrote:
>
> > Hi everyone.  I'm having an issue with select() working after an
> > insert.
>
> > See below for what I'm doing:
>
> > zulu ~/web2py % ./web2py.py -S welcome
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2010
> > Version 1.76.3 (2010-03-03 10:47:17)
> > Database drivers available: SQLite3
> > WARNING:root:import IPython error, use default python shell
> > Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12)
> > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.
> > (InteractiveConsole)>>> db=DAL('sqlite://test.db')
> > >>> db.define_table('test',Field('first','string'),Field('last','string'))
>
> > <CUT for readability>>>> db().select(db.test.id>0)
>
> > <gluon.sql.Rows object at 0x1920ff0>>>> 
> > db.test.insert(first='tara',last='birl')
> > 1
> > >>> db().select(db.test.id>0)
>
> > Traceback (most recent call last):
> >   File "<console>", line 1, in <module>
> >   File "/Users/tara/web2py/gluon/sql.py", line 3056, in select
> >     return self.parse(db,rows,self.colnames)
> >   File "/Users/tara/web2py/gluon/sql.py", line 3073, in parse
> >     field = table[fieldname]
> >   File "/Users/tara/web2py/gluon/sql.py", line 1556, in __getitem__
> >     return dict.__getitem__(self, str(key))
> > KeyError: 'id>0'>>> db.commit()
> > >>> db().select(db.test.id>0)
>
> > Traceback (most recent call last):
> >   File "<console>", line 1, in <module>
> >   File "/Users/tara/web2py/gluon/sql.py", line 3056, in select
> >     return self.parse(db,rows,self.colnames)
> >   File "/Users/tara/web2py/gluon/sql.py", line 3073, in parse
> >     field = table[fieldname]
> >   File "/Users/tara/web2py/gluon/sql.py", line 1556, in __getitem__
> >     return dict.__getitem__(self, str(key))
> > KeyError: 'id>0'

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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