Please... What i have to close after db.executesql() ???
If I try do it: print len(db(db.auth_user).select(limitby=(0,1))) In: def users_test(): try: raw_rows = db.executesql('CALL sp_recursive_start(1);') except Exception, e: db.rollback() raise e fields = [db.auth_user.generation, db.auth_user.id, db.auth_user.first_name] #rows = db._adapter.parse(raw_rows, fields=fields, colnames=['generation', 'id', 'first_name']) dv = DIV() if raw_rows: for row in raw_rows: #print row dv.append(DIV(row[2])) print len(db(db.auth_user).select(limitby=(0,1))) return dict(form=dv, subtitle=T('Users')) ... occur the same error: <type 'exceptions.TypeError'> 'NoneType' object is not iterable Can anyone help me please? On Sat, Feb 23, 2013 at 1:51 PM, __pyslan__ - Ayslan Jenken < ayslan.pyt...@gmail.com> wrote: > I commented the use of _adapter.parser, and the error no longer occurs, > but the data of db.executesql('CALL sp_recursive_start(1);') bring nothing > every other refresh. > > > On Sat, Feb 23, 2013 at 1:36 PM, __pyslan__ - Ayslan Jenken < > ayslan.pyt...@gmail.com> wrote: > >> Ok... I removed every try/except of my code to see the error logged by >> web2py. >> >> https://gist.github.com/pysI'm begginer in >> web2py...lan/5007364<https://gist.github.com/pyslan/5007364> >> >> >> The error occur every other refresh... >> >> <type 'exceptions.TypeError'> 'NoneType' object is not iterable >> >> ... in this line: >> >> if db(db.auth_user).isempty(): >> >> or >> >> if len(db(db.auth_user).select(limitby=(0,1))) <= 0: >> >> >> Because is the first code that use _adapter, maybe... If I comment this >> code the same error occur in other line: >> >> rows = db._adapter.parse(raw_rows, fields=fields, >> colnames=['generation', 'id', 'first_name']) >> >> >> Traceback (most recent call last >> ): >> File "/media/sda3/pyslan/PROJECTS/web2py/gluon/restricted.py", line 212, >> in restricted >> >> >> exec ccode in environment >> File >> "/media/sda3/pyslan/PROJECTS/web2py/applications/mchip/controllers/default.py" >> <http://127.0.0.1:8000/admin/default/edit/mchip/controllers/default.py>, >> line 109, in <module> >> >> >> File "/media/sda3/pyslan/PROJECTS/web2py/gluon/globals.py", line 193, in >> <lambda> >> >> >> self._caller = lambda f: f() >> >> >> File >> "/media/sda3/pyslan/PROJECTS/web2py/applications/mchip/controllers/default.py" >> <http://127.0.0.1:8000/admin/default/edit/mchip/controllers/default.py>, >> line 98, in users_test >> >> >> rows = db._adapter.parse(raw_rows, fields=fields, >> colnames=['generation', 'id', 'first_name']) >> >> >> File "/media/sda3/pyslan/PROJECTS/web2py/gluon/dal.py", line 1944, in parse >> >> >> for (i,row) in enumerate(rows): >> >> TypeError: 'NoneType' object is not iterable >> >> >> Sorry... I can't understand what happening yet... I don't know what I >> should to do... I'm begginer with web2py... >> >> >> >> On Sat, Feb 23, 2013 at 12:47 PM, Massimo Di Pierro < >> massimo.dipie...@gmail.com> wrote: >> >>> Moreover because the true cause of the problem is in a try/except the >>> actual error is not logged by web2py. >>> >>> >>> On Saturday, 23 February 2013 09:46:22 UTC-6, Massimo Di Pierro wrote: >>>> >>>> Have you removed the db statements inside try....except...? That's the >>>> cause of the problem. if a db command fails, the db may close connection >>>> and your driver raises an exception. Your code catches >>>> the exception and pretends to continue execution but the database is >>>> telling you the connection was closed. You cannot pretent nothing happened. >>>> >>>> Massimo >>>> >>>> On Saturday, 23 February 2013 09:35:55 UTC-6, __pyslan__ wrote: >>>>> >>>>> Hello everybody, >>>>> >>>>> I have not found a solution yet ... >>>>> Does anyone have any idea how I could do? >>>>> >>>>> >>>>> >>>>> Thanks... >>>>> >>>>> >>>>> >>>>> On Fri, Feb 22, 2013 at 9:33 AM, __pyslan__ - Ayslan Jenken < >>>>> ayslan...@gmail.com> wrote: >>>>> >>>>>> Well... >>>>>> >>>>>> Sorry, but the information about the code comment is wrong... >>>>>> >>>>>> I uncomment the code block "if db(db.auth_user).isempty():" and the >>>>>> error not thrown. >>>>>> >>>>>> With or without the code block above, in the terminal server is shown the >>>>>> error: >>>>>> >>>>>> DEBUG: connect attempt 0, connection error: >>>>>> >>>>>> Traceback (most recent call last): >>>>>> File "/home/ctx/PROJECTS/WEB/**web2py/gluon/dal.py", line 6853, in >>>>>> __init__ >>>>>> self._adapter = ADAPTERS[self._dbname](****kwargs) >>>>>> File "/home/ctx/PROJECTS/WEB/**web2py/gluon/dal.py", line 2402, in >>>>>> __init__ >>>>>> if do_connect: self.reconnect() >>>>>> File "/home/ctx/PROJECTS/WEB/**web2py/gluon/dal.py", line 588, in >>>>>> reconnect >>>>>> self.cursor = cursor and self.connection.cursor() >>>>>> AttributeError: 'NoneType' object has no attribute 'cursor' >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Fri, Feb 22, 2013 at 9:12 AM, __pyslan__ - Ayslan Jenken < >>>>>> ayslan...@gmail.com> wrote: >>>>>> >>>>>>> Hello, Massimo. >>>>>>> >>>>>>> With this change is launched this error: >>>>>>> >>>>>>> Traceback (most recent call last): >>>>>>> File "/ home/ctx/PROJECTS/WEB/web2py/**gluon/main.py", line 632, >>>>>>> in wsgibase >>>>>>> BaseAdapter.close_all_**instances ('rollback') >>>>>>> File "/ home/ctx/PROJECTS/WEB/web2py/**gluon/dal.py", line 543, >>>>>>> in close_all_instances >>>>>>> db._adapter.close (action) >>>>>>> File "/ home/ctx/PROJECTS/WEB/web2py/**gluon/dal.py", line 523, >>>>>>> in close >>>>>>> getattr (self, action) () >>>>>>> File "/ home/ctx/PROJECTS/WEB/web2py/**gluon/dal.py", line 1670, >>>>>>> in rollback >>>>>>> if self.connection: return self.connection.rollback () >>>>>>> ProgrammingError: (2014, "Commands out of sync, you can not run >>>>>>> this command now") >>>>>>> >>>>>>> >>>>>>> When this error occurs, I have to wait a while to access any other >>>>>>> page, even the ticket, because it generates new tickets. >>>>>>> This error is also thrown when I try to quickly update any other >>>>>>> page repeatedly. This error no longer occurs only when I comment the >>>>>>> code: >>>>>>> if db (db.auth_user). isempty () >>>>>>> >>>>>>> But still happening with the execution of the stored procedure. >>>>>>> >>>>>>> Thanks... >>>>>>> >>>>>>> >>>>>>> On Fri, Feb 22, 2013 at 12:22 AM, Massimo Di Pierro < >>>>>>> massimo....@gmail.com> wrote: >>>>>>> >>>>>>>> Does it work if you replace >>>>>>>> >>>>>>>> db(db.auth_user).isempty(): >>>>>>>> >>>>>>>> with >>>>>>>> >>>>>>>> len(db(db.auth_user).select(**limitby=(0,1))) >>>>>>>> * >>>>>>>> * >>>>>>>> *This is not a solution but can help me understand. >>>>>>>> * >>>>>>>> >>>>>>>> On Thursday, 21 February 2013 14:07:25 UTC-6, __pyslan__ wrote: >>>>>>>> >>>>>>>>> Sorry... >>>>>>>>> >>>>>>>>> The error occur on line 3 of this file: >>>>>>>>> >>>>>>>>> https://gist.github.com/**pyslan**/5007722<https://gist.github.com/pyslan/5007722> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Thu, Feb 21, 2013 at 4:45 PM, __pyslan__ - Ayslan Jenken < >>>>>>>>> ayslan...@gmail.com> wrote: >>>>>>>>> >>>>>>>>>> Hello, Erevybody! >>>>>>>>>> >>>>>>>>>> I am using MySQL on a project and created two procedures to >>>>>>>>>> perform a recursion, because users have users parents. >>>>>>>>>> >>>>>>>>>> The extra fields in the users table: >>>>>>>>>> https://gist.github.com/**pyslan**/5007384<https://gist.github.com/pyslan/5007384> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Performing some research and testing, I came to the code as >>>>>>>>>> follows: >>>>>>>>>> https://gist.github.com/**pyslan**/5007364<https://gist.github.com/pyslan/5007364> >>>>>>>>>> >>>>>>>>>> And the stored procedures [1]: >>>>>>>>>> >>>>>>>>>> https://gist.github.com/**pyslan**/5007439<https://gist.github.com/pyslan/5007439> >>>>>>>>>> >>>>>>>>>> https://gist.github.com/**pyslan**/5007414<https://gist.github.com/pyslan/5007414> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Running the first time the page is created normally and shows the >>>>>>>>>> page with the data correctly. If I refresh the page, generates the >>>>>>>>>> following error: >>>>>>>>>> <type'exceptions.TypeError'> 'NoneType' object is not iterable >>>>>>>>>> If I upgrade again, again shows the correct page, and so on. >>>>>>>>>> >>>>>>>>>> I tried with migrate = False, and the behavior continues. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Does anyone have any idea what is causing this error, or a >>>>>>>>>> correct way of doing this using web2py and stored procedures with >>>>>>>>>> MySQL? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, guys! >>>>>>>>>> [1] - Procedures adapted from that site: http://goo.gl/l6Nc2 >>>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>> >>>>>>>> --- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "web2py-users" group. >>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>> send an email to web2py+un...@googlegroups.com. >>>>>>>> For more options, visit >>>>>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>>>>>>> . >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> -- >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "web2py-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to web2py+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.