Upload file contents to database using C API

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bballr@gmail.com

    Upload file contents to database using C API

    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

  • Bill Karwin

    #2
    Re: Upload file contents to database using C API

    <bballr@gmail.c om> wrote in message
    news:1142432192 .786401.14640@e 56g2000cwe.goog legroups.com...[color=blue]
    > 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.[/color]

    You could use mysql_stmt_prep are() 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:


    Regards,
    Bill K.


    Comment

    Working...