最近找工作需要学习一些数据库方面的知识,所以就在实验室的树莓派上准备装个数据库试试,刚开始准备装一个mysql数据库,出现了很多问题,放弃了,后来查了一些资料原来还有很多可以用的小巧实用的数据库,sqlite就是其一,对于学习完全是够了。

     我的平台是树莓派+Linux raspberrypi 3.18.7-v7 +SQLite version 3.7.13。

     下载sqlite:sudo apt-get install sqlite3

                     sudo apt-get install libsqlite3-dev    (如果不安装,在c语言调用数据库头文件实用数据库API时会出错)

     版本检测:sqlite3 -version

     测试一下:

     新建.c文件:pi@raspberrypi ~/code/sqlite $ vi test_sqlite.c

 1 #include"stdio.h"
 2 #include"stdlib.h"
 3 #include"sqlite3.h"
 4 int main()
 5 {
 6       int result=0;
 7       sqlite3 *db=NULL;
 8       result=sqlite3_open("test.db",&db);
 9       printf("hello world\n,%d",result);
10       return 0;
11 }

      编译程序:gcc -o test_sqlite test_sqlite.c   -lsqlite3

      运行代码:pi@raspberrypi ~/code/sqlite $ ./test_sqlite 

      运行结果:pi@raspberrypi ~/code/sqlite $ ./test_sqlite 

                    hello world,0

 

      

 

相关文章:

  • 2022-01-06
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2021-07-28
  • 2022-01-24
  • 2022-12-23
猜你喜欢
  • 2021-10-11
  • 2021-04-11
  • 2021-08-14
  • 2022-12-23
  • 2021-10-26
  • 2021-05-18
  • 2022-01-03
相关资源
相似解决方案