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?
The
sourcecommand is a built-in command in themysqlclient program, it isn’t a SQL command. Your best bet is to either call themysqlclient program using the Csystemfunction (or an equivalent), or read the file text file yourself a command at a time and pass them to your query function.