mardi 26 janvier 2016

Python SQLITE OperationalError table has 201 columns but 1 values were supplied

I'm trying to copy one row of data from one table to another, but I'm stuck on this error:

"sqlite3.OperationalError: table testing has 201 columns but 1 values were supplied"

c_list = AAC, AAD, ABC, ABP, AGL, AHG, AHY, AIO, ALL, ALQ, ALU, AMC    

conn = sqlite3.connect(sqlite_file)
c = conn.cursor()

c.execute("INSERT INTO testing SELECT "'"%s"'" FROM prices ORDER BY rowid DESC LIMIT %s, 1" % (c_list, current_row))

I tried using SELECT * FROM but that threw up this error:

sqlite3.IntegrityError: UNIQUE constraint failed: testing.id

I think "'"%s"'" is probably the issue, but because some of the column names are sqlite keywords I have to escape them.

Can anyone provide some insight here please :D

Aucun commentaire:

Enregistrer un commentaire