How can I use pyodbc to create batched inserts

I'm using pyodbc (and Python) to load large amounts of data into Vertica.  The Vertica driver is going to change in the next couple of months so I don't want to lock myself into COPY v. LCOPY.  

I've read how to create batched inserts and I think I'm doing it correctly but it's still not performing the inserts in a batch.

Here's what I'm doing
  1. Opening a connection with autocommit turned off
  2. Opening a transaction
  3. Running parameterized, prepared insert statements (pyodbc.execute)
  4. Committing the transaction
I'm seeing the insert statements with no commits until the end but it's still slow relatively slow.  Is there another pyodbc command I should be running to do true batched inserts?

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file