Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second!
Background:
Try using SQLITE_STATIC
instead of SQLITE_TRANSIENT
for those inserts.
SQLITE_TRANSIENT
will cause SQLite to copy the string data before returning.
SQLITE_STATIC
tells it that the memory address you gave it will be valid until the query has been performed (which in this loop is always the case). This will save you several allocate, copy and deallocate operations per loop. Possibly a large improvement.