in reply to Writing data in chunks to a DB handle

The idea of doing a streaming upload into MySQL is a bad idea, because too many things can fail during the upload. Write the uploaded file to a temporary space and then use the MySQL bulk loading facility to import the data in a transaction.

If you're really hell-bent on doing it as a streaming upload, you can consider creating a pipe via mkpipe, writing to that pipe from your CGI upload process and having MySQL load from that pipe instead of a file.