Upload file contents to database using C API

Upload file contents to database using C API

am 15.03.2006 15:16:32 von bballr

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.

Brad

Re: Upload file contents to database using C API

am 15.03.2006 19:50:17 von Bill Karwin

wrote in message
news:1142432192.786401.14640@e56g2000cwe.googlegroups.com...
> 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.

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
segment.

See code example here:
http://dev.mysql.com/doc/refman/5.0/en/mysql-stmt-send-long- data.html

Regards,
Bill K.