接上一章 手把手教你北邮操作系统小学期实验六——Linux环境下嵌入式数据库mSQL的集成1
4.4. 参考示范程序,利用mSQL API,编写实现数据库访问功能的C语言程序
mSQL 主要API:
- mSQL的API函数库名称为libsql.a,一般位于mSQL安装路径下的lib目录中,库中的函数在msql.h中定义。用户在编写程序时,应包含该头文件,该文件一般位于mSQL安装路径下的inclube目录,如/usr/local/msql3/include中。另外,在对C程序进行编译链接的时候,应加上链接参数。
查询:
search.c
首先写代码:
gedit search.c
然后编译:
cc -c -B /usr/local/msql3/include/ search.c
cc -o search search.c -B /usr/local/msql3/lib -lmsql
最后运行:
./search student
//我的name忘记空格了,写的时候
修改:
update.c
getdit update.c
cc -c -B /usr/local/msql3/include/ update.c
cc -o update update.c -B /usr/local/msql3/lib -lmsql
./update student
./search student//可以通过刚才写的search查看一下是否真的修改成功了。
//我的name忘记空格了,写的时候
增加:
add.c
gedit add.c
cc -c -B /usr/local/msql3/include/ add.c
cc -o add add.c -B /usr/local/msql3/lib -lmsql
./search student
./add student
./search student//通过search来观察student表的变化
//我的name忘记空格了,写的时候
删除:
gedit delete.c
cc -c -B /usr/local/msql3/include/ delete.c
cc -o delete delete.c -B /usr/local/msql3/lib -lmsql
./search student
./delete student
./search student//通过search来观察student表的变化
完结!~ 撒花!
The End