tags:

views:

68

answers:

1

I have asked similar question before , here is detailed explanation of what i'm trying to achieve

I have two sqlite tables
table1 - is standard table - has fields like server,id,status table2 - has fields like server,id,status,number,logfile

Table2 is empty and Table1 has values. I'm trying to fill table2 with entries from table1. I can retrieve records from table1 ,but while trying to insert into table2 it fails.(but inserting a single field works)

self.cursor.execute("select * from server_table1 limit (?)",t)
#insert into server_process

for record in self.server_pool_list:
    print "--->",record # geting output like ---> (u'cloud_sys1', u'free', u'192.168.1.111')
    self.cursor.execute("insert into server_table2(server,status,id) values (?,?,?)",(record[0],)(record[1],),(record[2],));

And also let me know how to produce more useful error messages when insert fails

+1  A: 

This statement is broken:

self.cursor.execute("insert into server_table2(server,status,id) values (?,?,?)",(record[0],)(record[1],),(record[2],));

it should read:

self.cursor.execute("insert into server_table2(server,status,id) values (?,?,?)",record[0:2])

And you might want to look into executemany as I think it could save you a ton of time.

Omnifarious
thanks see my comment above. I'll also try your code.
lakshmipathi