views:

31

answers:

1

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, numbReadBases) \
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.

A: 

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)
Mark
Ah okay, that makes sense, thanks!
jeffhsu3