Dileep
Dileep

Reputation: 2425

How to write a c program for connecting to MySQL server and executing an SQL query?

I need to write a C program that connects to a MySQL server and executes an SQL query from a text file having a single query, in linux platform.

I am doing C programming for a while and also have elementary understanding in SQL.

Now my queries:

For this what are the packages i need to install in my linux system?

How can i do this(programming wise)?

Please give me a starting point where i could begin. Sample codes, links of sites covering this topic and other study materials will very helpful.

Thanks in advance

Upvotes: 0

Views: 1228

Answers (2)

Marc Alff
Marc Alff

Reputation: 8395

I need to write a C program that connects to a MySQL server and executes an SQL query from a text file having a single query, in linux platform.

If this is really all your program needs to do, and nothing else, it is already written ... you can use the mysql client:

mysql < my_file.sql

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798486

You must install a C compiler and the libmysql development files for your distro. After that you use the MySQL C API in your code, and link with the appropriate libraries when building.

Upvotes: 3

Related Questions