select insert record in shell

9 views
Skip to first unread message

John Frank

unread,
Sep 29, 2014, 3:44:38 AM9/29/14
to web...@googlegroups.com
i am starting to web2py and using shell for all db related stuff. today i notice a bizarre behavior on db select. Instead of selecting a record, it is insert value of last insert query. am i making any mistake here.. this my shell log:
In [5] : for x in row: print x
<Row {'id': 1L, 'name': 'dog'}>
<Row {'id': 2L, 'name': 'bug'}>
<Row {'id': 3L, 'name': 'y'}>

In [6] : db.dog.insert(name='hello')
4L

In [7] : db(db.dog).select()
<Rows (5)>

In [8] : db(db.dog._id > 0).select()
<Rows (6)>

In [11] : rows = db(db.dog).select()

In [12] : for x1 in rows: print x1
<Row {'id': 1L, 'name': 'dog'}>
<Row {'id': 2L, 'name': 'bug'}>
<Row {'id': 3L, 'name': 'y'}>
<Row {'id': 4L, 'name': 'hello'}>
<Row {'id': 5L, 'name': 'hello'}>
<Row {'id': 6L, 'name': 'hello'}>
<Row {'id': 7L, 'name': 'hello'}>

In [13] : db._lastsql
'SELECT  dog.id, dog.name FROM dog WHERE (dog.id > 0);'

In [14] : db(db.dog).select()
<Rows (10)>
 
Reply all
Reply to author
Forward
0 new messages