tags:

views:

191

answers:

1

I want to execute some mysql statements that are stored in a text file from my C program using the mysql.h library.

My inclination was to do something like the following, but this doesn't work:

mysql_query(conn, "source test.mysql");

This is because the SOURCE command is not a mysql statement in and of itself.

Is there a way call the SOURCE command programmatically and not from the command line?

+3  A: 

The source command is a built-in command in the mysql client program, it isn't a SQL command. Your best bet is to either call the mysql client program using the C system function (or an equivalent), or read the file text file yourself a command at a time and pass them to your query function.

Robert Gamble