Hello all

i just back to web2py a few weeks ago and i am still learning all the
new changes reading online official web2py book.

currently i am using web2py DALs in a non web-application , so to
parse and import data from text files into database (to update
records).


here is the example of what i am doing :

from gluon.sql import DAL,SQLTable,SQLField,Field
import os,time
import glob
db = DAL('mysql://r...@localhost/cds')
i=0
db.define_table('cdsdata',
                Field('docID','string'),
                Field('grpID','string'),
                Field('author','string'),
                Field('subject','string'),
                Field('sentto','string'),
                Field('cc','string'),
                Field('bcc','string'),
                Field('sentDate','string'),
                Field('type','string'),
                Field('extracted','text'),migrate=False)


rows=db(db.cdsdata.id>0).select('extracted')

for row in rows:
    row.update(extracted=open("./exp/" + row.values()[0].values()[0]
[-13:-1],'r').read())
    i+=1
    if i==1000:
        time.sleep(0.5)
        print "Updated Records : " + total
        i=0
        total+=1000

db.commit()
db.update()


well it tries to update the rows but , they are not actually updated
inside the database..

also , is row.update_record() method is never existed? coz i cant call
that function anymore..

but what weird is when i try to do :

db(db.cdsdata.id==1).update(extracted=" This is updated
text!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

it works flawlessly!

So row.update is dosen't really work ?
and row.update_record() never exist?
:


In [15]: row.update_record()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call
last)

/home/v3ss/db_importer/<ipython console> in <module>()

/home/v3ss/db_importer/gluon/sql.pyc in __getattr__(self, key)
    662
    663     def __getattr__(self, key):
--> 664         return dict.__getitem__(self,key)
    665
    666     def __setattr__(self, key, value):

KeyError: 'update_record'


Reply via email to