- temp_db_cursor.execute('CREATE TABLE {} ({})'.format(name, definition))
- if content is not None:
- temp_db_cursor.execute_values("INSERT INTO {} VALUES %s".format(name), content)
+ with psycopg.ClientCursor(temp_db_conn) as cur:
+ cur.execute('CREATE TABLE {} ({})'.format(name, definition))
+ if content:
+ sql = pysql.SQL("INSERT INTO {} VALUES ({})")\
+ .format(pysql.Identifier(name),
+ pysql.SQL(',').join([pysql.Placeholder() for _ in range(len(content[0]))]))
+ cur.executemany(sql , content)