Re: [Trac] how can all tickets be deleted at once?

135 views
Skip to first unread message

Hugo Milhomens

unread,
Jun 27, 2012, 7:18:19 AM6/27/12
to trac-...@googlegroups.com

Can you directly access the database?
If so, there are 3 tables that store ticket information.
ticket, ticket_history and i guess ticket_custom for the custom fields.
Just try a :
Delete from ticket;
Delete from ticket_history;
Delete from ticket_custom;

On Jun 27, 2012 7:16 AM, "christoph müller" <sto...@gmail.com> wrote:

this process is not for the usual bugtracking. but...

I'm testing trac for its ability to help in the process of building a classification system for information management (records management).

trac could be an exciting tool. I like it especially the possibility to create sql queries.

with the ticketimportplugin I read the structure into tickets.

users can submit their comments.

because the import gives not always the desired result, sometimes several attempts are necessary.

deleting all tickets at once would be a great help instead of set up the trac project new.

thanks for your comments.

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/trac-users/-/knE-obnu7-4J.
To post to this group, send email to trac-...@googlegroups.com.
To unsubscribe from this group, send email to trac-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.

Bas van der Vlies

unread,
Jun 27, 2012, 7:42:26 AM6/27/12
to trac-...@googlegroups.com
On 06/27/2012 09:24 AM, christoph müller wrote:
> this process is not for the usual bugtracking. but...
>
> I'm testing trac for its ability to help in the process of building a classification system for information management (records
> management).
>
> trac could be an exciting tool. I like it especially the possibility to create sql queries.
>
> with the ticketimportplugin I read the structure into tickets.
>
> users can submit their comments.
>
> because the import gives not always the desired result, sometimes several attempts are necessary.
>
> deleting all tickets at once would be a great help instead of set up the trac project new.
>
This is a code snippet from the email2trac package (delete_spam)
if you replace Spame with '*' vertyhing should work.


def new_delete_spam(parameters):
"""
This only works for trac versions higher or equal then 0.10
"""

debug = int(parameters['debug'])
DRY_RUN = parameters['DRY_RUN']
VERBOSE = parameters['VERBOSE']

project = parameters['project']


env = Environment(project, create=0)
db = env.get_db_cnx()

cursor = db.cursor()
cursor.execute("SELECT id FROM ticket WHERE component = 'Spam';")
while 1:
row = cursor.fetchone()
if not row:
break

spam_id = row[0]

if debug or DRY_RUN or VERBOSE:
print "Deleting ticket %s" %spam_id

try:
tkt = Ticket(env, spam_id, db)
except util.TracError, detail:
print detail
continue

if DRY_RUN:
print 'DRY_RUN: tkt.delete()'
else:
tkt.delete()

--
********************************************************************
* Bas van der Vlies e-mail: ba...@sara.nl *
* SARA - Academic Computing Services Amsterdam, The Netherlands *
********************************************************************



Reinhard Wobst

unread,
Jun 27, 2012, 11:54:54 AM6/27/12
to Trac Users
Another method is using the xmlrpc plugin:

import xmlrpclib

proxyURL = ...

p = xmlrpclib.ServerProxy(proxyURL)
all_ids = p.ticket.query('id != 0')
p.ticket.delete(all_ids)

This code is not tested but I used similar snippets extensivley,
no problems ...

Greetings

Reinhard

P.S.: The xmlrpc plugin is really good for many purposes!

christoph müller

unread,
Jun 28, 2012, 2:00:42 AM6/28/12
to trac-...@googlegroups.com
yeap, it worked!
i thought on foreign key constraints and was a bit afraid of just deleting the records. but it works proper.
the result can be seen under test environment http://ec2-54-247-30-133.eu-west-1.compute.amazonaws.com/newproject/report/10
thanks a lot.


Reply all
Reply to author
Forward
0 new messages