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 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.