h = tuple(next(id2))
create = 'CREATE TABLE id2 (%s varchar, %s int PRIMARY KEY, %s int)' % h
insert = 'INSERT INTO id2 (%s, %s, %s) VALUES (%%s, %%s, %%s)' % h
psycopg2 equivalent to R dbWriteTable command and getting more performance from python code