Upload file contents to database using C API

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
What I am trying to do is to take the contents of a very large text
file and place it into a LONGTEXT field in a database.  I am looking
for a solution using the C API to help me handle this.  The code I use
right now is very ineffecient.  I basically use a VERY large character
array that is like 600,000 characters long and store an UPDATE query to
the database in this.  I place the contents of the file being uploaded
into this query where I SET the LONGTEXT field to the file contents.  I
know there has to be a much better way of handling this, so if you have
any ideas, please let me know.  Thanks alot.


Re: Upload file contents to database using C API

Quoted text here. Click to load it

You could use mysql_stmt_prepare() to prepare a parameterized SQL statement,
using ? in place of the value for the LONGTEXT field.  Then use
mysql_stmt_send_long_data() to push the data to the server segment by

See code example here:

Bill K.

Site Timeline