0
鉴于Postgres的查询转换:postgres的:不是所有的参数期间字符串格式化
INSERT INTO net.bgp_communities (comm_name, comm_value) VALUES (%s, %s) ;
和
('blabla', 'target:*:*')
所得查询(使用mogrify
)数据
INSERT INTO net.bgp_communities (comm_name, comm_value) VALUES ('blabla', 'target:*:*') ;
其导致
TypeError('not all arguments converted during string formatting',)
我相信错误来自最后没有,
的元组?但这怎么解决呢?
编辑:
描述如何查询与使用元组psycopg2一起呈现
curs.executemany("""INSERT INTO net.bgp_communities (comm_name, comm_value) VALUES (%s, %s)""", msg)
只有当元组只有一个元素时,才需要''元组末尾的','。例如。 '('a',)'是一个元组,'('a')'不是。 – Kendas
谢谢!任何想法谁给出如何'psycopg2'渲染查询? – iamsterdam
请给出产生错误的'mogrify'的确切电话。 – chepner