Error executing a query in python with sqlite

1

I'm trying to insert into a table. This is the code I made:

cursor=connection.cursor()  
cursor.execute('INSERT INTO TopOperadores (imsi_pref_top,descarga_top,transferencia_top) VALUES (SELECT imsi_num, AVG(descarga), AVG(transferencia) FROM Trafico_de_Datos group by nomb_oper)')  

This is the error:

  

syntax error at or near "SELECT" LINE 1:   ..._ pref_top, download_top, transfer_top) VALUES (SELECT ims ...

    
asked by Coloma 16.05.2016 в 05:53
source

1 answer

0

It is not necessary to add VALUES to your query since you determined 3 fields in which the values of SELECT were inserted, the correct thing would be:

INSERT INTO TopOperadores (imsi_pref_top,descarga_top,transferencia_top) 
SELECT imsi_num, AVG(descarga), AVG(transferencia) FROM Trafico_de_Datos group by nomb_oper
    
answered by 16.05.2016 / 18:17
source