Hello viniciusban! The line "db.commit()" solved these 2 problems, thank you very much!
Regarding to why I used "update_record()" without parameters, I took it from an example I saw on Internet, maybe the example was wrong or maybe (probably) I missunderstood the example. Thank you very much again! El domingo, 30 de diciembre de 2012 01:57:15 UTC+1, viniciusban escribió: > > On Sat, Dec 29, 2012 at 10:19 PM, Wonton <rfer...@gmail.com <javascript:>> > wrote: > > Hello everyone and happy new year! > > Hi. > > > > > I'm having an issue regarding the updating and deletion of a row in my > > tables and I can't find any solution, so I hope you can help me. > > > > 1) Regarding to the update: > > As far as I know, to update a row I should do something like this: > > query = db(db.table.field1=='What I am looking for') > > query.update(field2='hello') > > rows = query.select() > > Issue a db.commit() here > > > > > row = rows[0] > > row.update_record() > > > > But this is not working, it doesn't update the row. > > Probably you have a transaction issue. > > BTW, your update_record() doesn't change any field content. What are > you trying to do with it? > > > > > > So, I'm confused about the use of update and update_record, is ok if I > only > > use update(...)? > > Actually, update() would be preferred over update_record() because it > generates a SQL UPDATE statement. On the other hand, update_record() > generates a SQL UPDATE after the record has been read, via SQL SELECT. > > Thinking "transactionally", you should use update() all the time. > update_record() would be for a few situations. > > > > > 2) Regarding to the delete: > > I'm deleting a row with this code: > > query = db(db.table.field1=='What I am looking for') > > deletedRow = query.delete() > > Again, try to db.commit() here, after query.delete() > > > The problem is that if I open this table with Database AppAdmin and > refresh > > it, the (supposed deleted) row is still there. > > Is the row really deleted, I guess not, so what could I be doing wrong? > > Remind Web2py issues an automatic db.commit() at the end of every > succesful request, but if you're in Web2py shell, there's no "end of > request". So, you should db.commit() by yourself. > --