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
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