On 05/13/2012 02:50 PM, Anthony wrote:
ids = db()._select(db.users_keywords.keyword_id, distinct=True)
db((~db.keyword.id.belongs(ids)) (db.keyword.dictionary == dictionary)).
delete()
Anthony
Thanks a lot!
This is exactly what I was looking for!
--
Vincenzo Ampolo
Vincenzo,
You may get exceptions from the database driver if the id list is empty.
Using Postgres, I do something like this:
ids = db()._select(db.users_keywords.keyword_id, distinct=True)
if len(ids):
db((~db.keyword.id.belongs(ids)) (db.keyword.dictionary ==
dictionary)).
delete()
You may get exceptions from the database driver if the id list is empty.
Using Postgres, I do something like this:
ids = db()._select(db.users_keywords.keyword_id, distinct=True)
if len(ids):
db((~db.keyword.id.belongs(ids)) (db.keyword.dictionary ==
dictionary)).
delete()
On 05/13/2012 12:02 AM, Andrew wrote:
Does replacing select with delete work?
Nope, i got:
TypeError: delete() got an unexpected keyword argument 'join'
It seems that delete does not accept any argument at all!
Yeah. I want to delete from db.keyword
If delete was more like select() would
db((db.keyword.id!=db.users_keywords.keyword_id)(db.keyword.dictionary==dictionary)).delete(db.keyword)
Exactly what set of records are you trying to delete from db.keyword? Are
you trying to identify keywords that are not referenced by any records in
db.users_keywords? If so, how about
Hi,
In the web2py book I've seen simple delete queries like:
db(db.person.id 3).delete()
where it's easy to understand that the persons with id 3 will be
deleted from db.person.id
but what if i want to delete rows selected with this query:
Not that I've tried it, but does this syntax from the book help ?
rows = db(db.person).select(join=db.dog.on(db.person.id==db.dog.owner))
Does replacing select with delete work?
P.s. I assume you are wanting to delete from keyword ? That is why it is
ambiguous with joins, which one is the target ?
8 matches
Mail list logo