Hi all,
On Dec 22, 12:43 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > db=SQLDB(...) > def timer(db,f): > import time,os > import gluon.portalocker > myfile=open(os.path.join > (request.folder,'databases','sql.log'),'a') > gluon.portalocker,lock(myfile, gluon.portalocker.LOCK_EX) > t0=time.time() > f() > t0=time.time()-t0 > gluon.portalocker,unlock(myfile) > myfile.wriite('%s: %s\n' % (t0,db._lastsql) > db._execute=lambda *a,**b: timer(db,lambda:db._execute(*a,**b)) Unfortunately the above code doesn't work for for GAE. I tried the following solution in my model: import time, logging class DatabaseDecorator(GQLDB): def __timer(self, where): if not self._lastsql: value = GQLDB.__call__(self, where) else: t0 = time.time() value = GQLDB.__call__(self, where) t1 = time.time() - t0 logging.critical('%s : %.0f ms' % (self._lastsql, t1)) return value def __call__(self, where=''): return self.__timer(where) db=DatabaseDecorator() # connect to Google BigTable There's only one big problem: GQLDB._lastsql gives you Google's "Query" object, which doesn't have a string representation. I wonder if there's an easy way to store the query string in GQLDB, as GQLDB._lastsqlstring or something? Sincerely, --Jonathan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---