473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

mySQL and C question

QQ
Hello

I am accessing a mySQL database through C.
I am reading some books and testing the program.
However, I didn't find some explanations that I am curious.
My question is:

If I access the database through C, do I need to create
a database at mySQL first and create table by mySQL too.
Then I can use C to insert, update, delete the rows.

Or can I do all the things through C such as create a database, insert
and update..... ? If I can, how can I do it?

Thanks a lot!

Nov 14 '05 #1
5 1176

"QQ" <ju****@yahoo.com> wrote

I am accessing a mySQL database through C.
Or can I do all the things through C such as create a database, insert
and update..... ? If I can, how can I do it?

As far as C is concerned sql is just another third party api. It is rather
powerful because it can access huge databases very quickly, but still just a
normal set of function calls.
It would be very surprising if your implementation didn't give facilties for
creating and editing databases, though you might need permissions to edit
existing databases. However the details aren't on topic here.
Nov 14 '05 #2
>If I access the database through C, do I need to create
a database at mySQL first and create table by mySQL too.
Then I can use C to insert, update, delete the rows.

Or can I do all the things through C such as create a database, insert
and update..... ? If I can, how can I do it?


Using the MySQL C API, you can generate the queries as C strings
and then run them with mysql_query(), assuming that the MySQL login
you are using from C has sufficient privileges to do what you want
it to do (create databases, create tables, alter tables, drop
databases, etc.) sprintf() might be convenient to generate queries
with values substituted into the query.

Gordon L. Burditt
Nov 14 '05 #3
# If I access the database through C, do I need to create
# a database at mySQL first and create table by mySQL too.
# Then I can use C to insert, update, delete the rows.

The MySQL interface just opens a channel to the server through which you
send whatever queries you wish, including create database or table, or
grants, selects, inserts, etc, as character strings. The server has to
be running.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
The whole world's against us.
Nov 14 '05 #4
SM Ryan wrote:

# If I access the database through C, do I need to create
# a database at mySQL first and create table by mySQL too.
# Then I can use C to insert, update, delete the rows.


Your squirrel is off topic.

--
pete
Nov 14 '05 #5
QQ <ju****@yahoo.com> wrote:
If I access the database through C, do I need to create a database at mySQL
first and create table by mySQL too. Then I can use C to insert, update,
delete the rows.

Or can I do all the things through C such as create a database, insert and
update..... ? If I can, how can I do it?


You can simply use MySQL API calls to do all that from within your C programs.
After all, the MySQL tools are also written in C, using the same library.

The MySQL C API documentation is very complete, and can be found here:

<http://dev.mysql.com/doc/mysql/en/c.html>

Basically, you just have to make a connection to your MySQL server, properly
authenticated so it's allowed to do the things you want to do, then you'll
have to prepare a statement ('query') of the things you want done, and fire it
off to the server over the connection you opened. Check errors, disconnect.

- Philip

--
Philip Paeps Please don't email any replies
ph****@paeps.cx I follow the newsgroup.

It is ok to be ignorant in some areas,
but some people abuse the privilege.
Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Westcoast Sheri | last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database (2 columns: "fruit" and "quantity")....so can we make these following mySQL queries work somehow? (visitor buys 5...
0
by: MJL | last post by:
This is a mysql/php question (but a little more on the mysql side.) The two are so closely related these days, I thought it would be ok to ask here. I installed on my Suse Linux system mysql 4.0...
8
by: Tony Clarke | last post by:
Hi, Just a quick question about performance with MySQL & PHP. If I had a table in a MySQL database with about 100,000 records in it and I need to find the last record is there a quick way to do...
2
by: pieter_hordijk | last post by:
Hi all, maybe this isn't a php question, but a MySQL question. If so I'm sorry for asking you guys to help me :) I know this question is asked often in NGs, but I couldn't find the answer...
2
by: kimshapiro100 | last post by:
Question on PhP, MySQL I am thinking of a consumer internet business for which I will have to have a database driven site built. I am thinking of using PhP, MySQL as the main technologies...
39
by: Mairhtin O'Feannag | last post by:
Hello, I have a client (customer) who asked the question : "Why would I buy and use UDB, when MySql is free?" I had to say I was stunned. I have no experience with MySql, so I was left sort...
1
by: Jim Carlock | last post by:
I have a couple questions about MySQL involving which version of MySQL to use. I'm looking for minimal memory use on a Windows XP machine. Which version would be best for this? And can anyone...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
5
by: news.telia.net | last post by:
Hi! I have a question. I have installed php and mysql on an apache-server on windows and I can't connect to the server. I tried to create a database (since I am trying to learn howto). My...
27
by: gerrymcc | last post by:
Hello, I'm a php/mysql beginner... Is there any way of making the mysql command line client full-screen? Sometimes it's easier to use the client than go thru php, but since it's only about 80...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.