I need to insert multiple rows with one query (number of rows is not constant), so I need to execute query like this one:
INSERT INTO t (a, b) VALUES (1, 2),
execute_batch has been added to psycopg2 since this question was posted.
It is slower than execute_values but simpler to use.