나는 간단한 다중 삽입에 대한 psycopg2 executemany를 사용하기 위해 노력하고있어하지만 난 단지 그것을 DICT를 사용하여 작업 할 수없는 가치 "일반"순서 :간단한 목록이있는 psycopg2 executemany?
# given:
values = [1, 2, 3] ; cursor = conn.cursor()
# this raises TypeError: 'int' object does not support indexing:
cursor.executemany('INSERT INTO t (col_a) VALUES (%s)', values)
# I also tried encapsulating my 'values' into a tuple/list but it gives another exception (TypeError: not all arguments converted during string formatting).
# while this is ok:
cursor.executemany('INSERT INTO t (col_a) VALUES (%(value)s)', [ dict(value=v) for v in values ])
는 "는 제공 할 수 없습니다 "명명 된"매개 변수 (% (value) s)를 사용하지 않고 값의 단순한 "list/tuple?
Janne & Fog에게 감사의 말을 전하겠습니다. – gst