DB Query Parse Hangup

M

Merrigan

Hi There,

I have been working on this script, and the part that this issue that
I have occurs in is when iterating through some results from the db,
asking the admin input to delete the entry or not - everything works
fine up until the last entry, then it bombs out. I know why - but I am
not quite sure how to fix it:

The Code:

select_statement = "SELECT source, destination FROM mail.forwardings
WHERE destination = '%s'" % e_mail

result = db_cursor.execute(select_statement)
if result >= 1:
aliasLine = 0
number = result - 1
while aliasLine <= number:
db_cursor.execute(select_statement)
answer = db_cursor.fetchall()
answer_1 = answer[aliasLine]
aliasLine = aliasLine + 1
print '%s is still linked to %s.' % (answer_1[0], answer_1[1])
#to_edit = raw_input("Please provide one of the above mentioned E-
Mail Aliases to edit: ")
to_do = str.lower(raw_input("Would you like to Delete(D) or
Modify(M) the alias? [D/M] "))
delete = 'd'
modify = 'm'
if to_do == delete:
del_statement = "DELETE FROM forwardings WHERE source = '%s'" %
answer_1[0]
db_cursor.execute(del_statement)
print "Alias '%s', has been successfully deleted." % answer_1[0]
elif to_do == modify:
print "WILL BE MODIFIED"

any help will be much appreciated.

Thank you!
-- Merrigan
 
G

Gabriel Genellina

I have been working on this script, and the part that this issue that
I have occurs in is when iterating through some results from the db,
asking the admin input to delete the entry or not - everything works
fine up until the last entry, then it bombs out. I know why - but I am
not quite sure how to fix it:

You could get some help if you explain what you mean by "it bombs out"
(the program stops with an exception? post the full traceback), and since
you know "why", telling it would be a good thing too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top