I am reading data from a .mat file using the Pytables module. After reading the data, I want to insert this data into the database using psycopg. Here is a sample code piece:
file = tables.openFile(matFile)
x = 0
#populate the matData list
for var in dest:
data = file.getNode('/' + var)[:]
matData.append(data)
x = x+1
#insert into db
for i in range(0,x):
cur.execute("""INSERT INTO \"%s\" (%s) VALUES (%s)""" % tableName,dest[i],matData[i]) )
I am getting the following error:
Traceback (most recent call last):
File "./loadDBFromMAT.py", line 111, in <module>
readInputFileAndLoad(args.matFileName,args.tableName)
File "./loadDBFromMAT.py", line 77, in readInputFileAndLoad
cur.execute("INSERT INTO \"%s\" (%s) VALUES (%s)" % (tableName,dest[i],matData[i]) )
psycopg2.ProgrammingError: syntax error at or near "["
LINE 1: INSERT INTO "DUMMY1km" (data) VALUES ([[-3000 -3000 -3000 .....
It would be great if anyone can suggest a workaround for this. Thanks!