What's id_s? Am getting error that id_s not defined

On Sun, 22 Jul 2018, 14:33 sandeep patel <patelsandeep...@gmail.com> wrote:

> You can delete row this way!!
> db((db.table.id==id_s)&(db.table.created_by == auth.user.id)).delete()
> if you want delete rows upto a certain limit so you can you put this
> quarry under for loop.
> Best,
>
> On Sun, Jul 22, 2018 at 4:43 PM Maurice Waka <mauricew...@gmail.com>
> wrote:
>
>> I have tried this example but I get this error below:
>>
>>
>> db(query).delete()
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line 2277, 
>> in delete
>>  ret = db._adapter.delete(table, self.query)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/sqlite.py", 
>> line 86, in delete
>>  deleted = [x[table._id.name] for x in db(query).select(table._id)]
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line 2250, 
>> in select
>>  return adapter.select(self.query, fields, attributes)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/sqlite.py", 
>> line 82, in select
>>  return super(SQLite, self).select(query, fields, attributes)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
>> 757, in select
>>  colnames, sql = self._select_wcols(query, fields, **attributes)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
>> 672, in _select_wcols
>>  query = self.expand(query, query_env=query_env)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
>> 434, in _expand
>>  rv = op(first, second, **optional_args)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/dialects/base.py", line 
>> 228, in _and
>>  self.expand(second, query_env=query_env))
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/dialects/__init__.py", 
>> line 96, in expand
>>  return self.adapter.expand(*args, **kwargs)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
>> 453, in _expand
>>  return str(rv)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line 2090, 
>> in __repr__
>>  return '<Set %s>' % str(self.query)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line 1963, 
>> in __str__
>>  return str(self.db._adapter.expand(self))
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
>> 434, in _expand
>>  rv = op(first, second, **optional_args)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/dialects/base.py", line 
>> 344, in eq
>>  self.expand(second, first.type, query_env=query_env))
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/dialects/__init__.py", 
>> line 96, in expand
>>  return self.adapter.expand(*args, **kwargs)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
>> 444, in _expand
>>  rv = self.represent(expression, field_type)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
>> 381, in represent
>>  return super(SQLAdapter, self).represent(obj, field_type)
>>  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
>> 334, in represent
>>  obj = obj()
>> TypeError: id() takes exactly one argument (0 given)
>>
>> Issues:
>>
>> 1. What could be wrong.
>>
>> 2. Is there a way of following this example but deleting rows upto a certain 
>> limit, say anything above 50 like in this example:
>>
>> DELETE FROM post WHERE id IN(SELECT id FROM post ORDER BY id LIMIT 50 ASC
>> )
>>
>>
>> On Sunday, October 15, 2017 at 4:03:12 AM UTC+3, 黄祥 wrote:
>>>
>>> think you can do it by store the user created id (auth.signature or code
>>> it by your self) in your table and use it as a condition
>>> *e.g. not tested*
>>> query = ((db.table.id == id) & (db.table.created_by == auth.user_id) )
>>> db(query).delete()
>>>
>>> best regards,
>>> stifan
>>>
>>>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> 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/d/optout.
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/LPxSiL3u0MI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to