I am new on this. I did the following programming sequence in order to delete all rows from a table i have created recently.
import sqlite3
con=sqlite3.connect('prueba.db')
cur=con.cursor()
cur.execute('''CREATE TABLE tabla1(ExtremoA text,ExtremoZ text,PotenciaRxA real,PotenciaTxA real,PotenciaRxZ real,PotenciaTxZ real,SpanLossAZ real,SpanLossZA real)''')
print "Tabla1 creada exitosamente"
cur.close()
con.close()
con=sqlite3.connect('prueba.db')
cur=con.cursor()
registros=[('Quillota','San felipe',-9,4,-11,3,15,12),('San Felipe','Las Cuevas',-10,2,-12,6,16,14)]
sql='''INSERT INTO tabla1(ExtremoA,ExtremoZ,PotenciaRxA,PotenciaTxA,PotenciaRxZ,PotenciaTxZ,SpanLossAZ,SpanLossZA)VALUES(?,?,?,?,?,?,?,?)'''
cur.executemany(sql,registros)
con.commit()
print "registros creados exitosamente"
cur.execute('''SELECT * FROM tabla1''')
todo=cur.fetchall()
print todo
print len(todo)
for i in range(len(todo)):
cur.execute('''DELETE FROM tabla1 WHERE rowid=?''',(i,))
con.commit()
print "número total de filas borradas:", con.total_changes
cur.close()
con.close()
My Table "tabla1" have two entries. When python finishes and I perform SELECT and fetchall once more, I realize that only the first entry has been deleted. What is the problem?. should I declarate or create a rowid column field at the beginning ?. Sorry for my grammar.