2

SQL command to delete all users with karma 1
 

I have more than 2000 user accounts which need to be deleted. In the /admin/ page I cannot filter these users out.

Is there perhaps an SQL command that allows me to delete all the users with karma 1 (or users without any posts).

To be sure -- because I am not very technical -- what is an SQL to backup the database first. And what would be to a SQL command that lists all the users satisfying my criteria. Just want to be sure that I don't delete all users.

Thanks :)

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
kristof's avatar
51
kristof
asked 9 years ago
Evgeny's avatar
13.2k
Evgeny
updated 8 years ago

Comments

see more comments

1 Answer

-1

You might log in to the django shell:

python manage.py shell

Then type :

from askbot.models import User
uu = User.objects.filter(askbot_profile__reputation=1) #or (reputation=1) for versions < 0.8
for u in uu:
    try:
        u.delete()
    except:
        pass

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
answered 9 years ago
link

Comments

can it be done with UI?

Andy's avatar Andy (9 years ago)
see more comments