Sorry this is a very newbie question. When I'm trying to pass a tuple into an insert statement the quotations seem to disappear.
line=[0, 1, 3000248, 'G', 'T', 102, 102, 60, 25]
SNPinfo = tuple(line)
curs.execute("""INSERT INTO akr (code, chrID, chrLOC, refBase, conBase, \
consqual, SNPqual, maxMapqual, numbR开发者_Python百科eadBases) \
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)""", SNPinfo)
The Error I get is: LINE 1: ...axMapqual, numbReadBases) VALUES (0,1,3000248,G,T,102,10.. psycopg2.ProgrammingError: column "g" does not exist
I think my insert statement is wrong somewhere.
You are missing the single quotes around the varchars on your string formatting:
curs.execute("""INSERT INTO akr (code, chrID, chrLOC, refBase, conBase, \
consqual, SNPqual, maxMapqual, numbReadBases) \
VALUES (%s,%s,%s,'%s','%s',%s,%s,%s,%s)""", SNPinfo)
This would produce:
INSERT INTO akr (code, chrID, chrLOC, refBase, conBase,
consqual, SNPqual, maxMapqual, numbReadBases)
VALUES (0,1,3000248,'G','T',102,102,60,25)
精彩评论