Environment: SCOOpenServer5.0.6, mysql3.23.42, gcc2.95.2 note: gcc has integrated functions that support mysql. you can directly call the database in the C source code without using ESQLC embedded calls like informix. 1. makefile file CCgccLIB-lcurses-lsocket-lmysqlclient-lm-lc-lnslall: gspsergspser: get_dat environment: SCO OpenServer 5.0.6, mysql 3.23.42, gcc 2.95.2
Note: gcc has integrated functions that support mysql. you can directly call the database in the C source code without using ESQL/C embedded calls like informix.
1. makefile
CC = gcc
LIB =-lcurses-lsocket-lmysqlclient-lm-lc-lnsl
All: gspser
Gspser: get_data.o getfileargv. o
$ (CC)-o gj get_data.o getfileargv. o $ (LIB)
Get_data.o: get_data.c
$ (CC)-c get_data.c
Getfileargv. o: getfileargv. c
$ (CC)-c getfileargv. c
Clean:
Rm-f *. o
2. get_data.c file
# Include
# Include
# Define DBCFG "./gsp. conf"
Main ()
{
Char dbhost [32], dbuser [16], dbpasswd [16], db [16];
Char query [256];
Int count;
MYSQL * mysql;/* indicates the handle to a database connection */
MYSQL_RES * mysql_res;/* indicates the result of a query in the returned row */
MYSQL_ROW mysql_row;/* string array */
My_ulonglong rows;
/* This type is used for row numbers, mysql_affected_rows (), mysql_num_rows (), and mysql_insert_id ()
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.