我正在使用Postgres 9和Python 2.7.2以及psycopg2,并试图插入带正确转义的引号的字符串值数组。示例:Postgres/psycopg2 - 插入字符串数组
metadata = {"Name": "Guest", "Details": "['One', 'Two', 'Three']"}
cur.execute("insert into meta values ('%s');" % metadata)
会抛出异常:
psycopg2.ProgrammingError: syntax error at or near "One"
LINE 1: "Details": "['One...
^
我也尝试使用Postgres的E反斜杠逃脱一起,但还没有找到正确的组合呢。想法?
你用'''''''',''''''''''''''得到了什么错误? – agf