sudo apt-get install httpd 或是找httpd 安装包
找到后,做如下 *** 作,一般安装包一类的 *** 作都差不多这样做;./configure -prefix=/var/httpd
makesudo make install
sudo vim /var/httpd/conf/httpd.conf
Listen 8080
user akaedu
group akaedu
servername 127.0.0.1:8080
/bin下
sudo ./httpd -k start
http;//127.0.0.1:8080
/var/httpd/httpdoc/下就可以写我们自己的服务文件了;
sqllite3:------------------------------------------------------------
sudo apt-get install sqlite3
sudo apt-get install rlwrap // 是一个可以支持上下键的软件
rlwrap sqlite3 test.db
.bashrc //改个好用的别名
alias sqlite3='rlwrap sqlite3'
export PS1='-->'
sqlite3 m.db //在打开一个文件的时候如果当前目录没有后面的这个m.db的话,会自己建一个m.db 的database;
create table student(ID integer,name text,age integer,score integer); //建表
.table //看表
.schema student 看表里面当前有多少字段;
记录内容的 *** 作:
insert into student(ID,name,age,score) values(1,'xiaoMing',21,100);
not null,primary key,unique,
select * from student;
delete from student;
.import data.txt student; 自己写字txt文件可以把它导入进来。注意内容要以|分格
update student set age=27 where ID=2;
delete from student where ID =1;
name like 'X%' //支持like 等 *** 作
age between 22 and 25;
distinct name //过滤相同的
order by ID desc/ascscore+socre2
select * from sapplay union all select * from custom; 两表连查
2.
create table employee(ID integer primary key,depart text,salary integer);
select sum(salary) from employee;
select depart,sum(salary) from employee group by depart;
select depart,sum(salary) from employee group by depart having sum(salary)>3000;
select depart,sum(salary) from employee where ID<5 group by depart having sum(salary) >5000;
表的修改:
alter table student add score2 integer;
alter table student modify score2 text;(不一定支持)
drop table student;
create table employee_bak as select * from employee;//bak
上前的内容基本上和我们一般用的sql差不多,看看那个这个也就会了,不过有的时候我们这个小sql会不支持;
下面是用sqlite3 在C语言下的 *** 作:
#include <stdio.h>#include <stdlib.h>#include <sqlite3.h> int rscallback(voID *p,int argc,char **argv,char **argvv){ int i; *(int *)p = 0; for(i=0; i<argc; i++) { printf("%s=%s ",argvv[i],argv[i]?argv[i]:"NulL"); } putchar('\n'); return 0;} int main(voID){ sqlite3 *db; char *err = 0; int ret = 0; int empty = 1; ret = sqlite3_open("./test.db",&db); if(ret != sqlITE_OK) { fputs(sqlite3_errmsg(db),stderr); fputs("\n",stderr); exit(1); } /*ret = sqlite3_exec(db,"insert into employee values(12,\"www\",\"male\",31);",rscallback,∅,&err); if(ret != sqlITE_OK) { fputs(err,stderr); sqlite3_close(db); exit(1); }*//* if(empty) { fputs("table employee is empty\n",stderr); exit(1); }*/ ret = sqlite3_exec(db,"select * from employee;",stderr); sqlite3_close(db); exit(1); } if(empty) { fputs("table employee is empty\n",stderr); exit(1); } sqlite3_close(db); return 0;}
动态实现insert update
#include <stdio.h>#include <stdlib.h>#include <sqlite3.h> static int sort_callback(voID *p,char **argvv){ int i; int time = *(int *) p; time++; *(int *) p = time; printf("[%d]: ",time); for(i = 0; i < argc; i++) printf("%8s ",argv[i]? argv[i]: "NulL"); printf("\n"); return 0; }int do_insert(sqlite3 *db){ int ret = 0; char name[10]; char gender[10]; char score_a[10]; char score_b[10]; char score_c[10]; char *sql = NulL; printf("input name:\n"); scanf("%s",name); printf("input Gender:\n"); scanf("%s",gender); printf("input score A:\n"); scanf("%s",score_a); printf("input score B:\n"); scanf("%s",score_b); printf("input score C:\n"); scanf("%s",score_c); printf("name:%s,Gender:%s,score A:%s,score B:%s,score C:%s\n",gender,score_a,score_b,score_c); sql = sqlite3_mprintf("insert into student values(%Q,%Q,%s,%s)",score_c); ret = sqlite3_exec(db,sql,NulL,NulL); sqlite3_free(sql); if(ret != sqlITE_OK) { fputs("insert error\n",stderr); } return ret;} int do_delete(sqlite3 *db){ int ret = 0; char name[10]; char *sql = NulL; printf("input name:\n"); scanf("%s",name); sql = sqlite3_mprintf("delete from student where name=%Q",name); ret = sqlite3_exec(db,NulL); sqlite3_free(sql); if(ret != sqlITE_OK) { fputs("delete error\n",stderr); } return ret;}int do_update(sqlite3 *db){ int ret = 0; char name[10]; char gender[10]; char score_a[10]; char score_b[10]; char score_c[10]; char *sql = NulL; printf("input name:\n"); scanf("%s",score_c); sql = sqlite3_mprintf("update student set " "gender=%Q,scoreA=%s,scoreB=%s," "scoreC=%s where name=%Q",score_c,name); ret = sqlite3_exec(db,NulL); sqlite3_free(sql); if(ret != sqlITE_OK) { fputs("update error\n",stderr); } return ret;}int do_sort(sqlite3 *db){ int ret = 0; int time = 0; ret = sqlite3_exec(db,"select name,scoreA," "scoreB,scoreC,scoreA+scoreB+scoreC " "from student order by scoreA+scoreB+scoreC desc",sort_callback,&time,NulL); if(ret != sqlITE_OK) { fputs("sort error\n",stderr); } return ret;}voID displaymenu(voID){ printf("1. Insert Record\n"); printf("2. Delete Record\n"); printf("3. Update Record\n"); printf("4. Sort\n"); printf("q. quit\n"); printf("Please Select [1-4]:\n"); return; } int main(voID){ sqlite3 *db; char *err = 0; int ret = 0; int empty = 1; int options = 0; int donext = 1; ret = sqlite3_open("./test.db",&db); if(ret != sqlITE_OK) { fputs(sqlite3_errmsg(db),stderr); fputs("\n",stderr); exit(1); } displaymenu(); while(donext) { options = getchar(); switch(options){ case '1': { do_insert(db); displaymenu(); } break; case '2': { do_delete(db); displaymenu(); } break; case '3': { do_update(db); displaymenu(); } break; case '4': { do_sort(db); displaymenu(); } break; case 'q': { donext = 0; } break; default: { } break; } } sqlite3_close(db); return 0;}由于用到sqlITE库,所以编译的时候要加-lsqlite3 总结
以上是内存溢出为你收集整理的httpd 安装 、sqlite3安装 学习笔记全部内容,希望文章能够帮你解决httpd 安装 、sqlite3安装 学习笔记所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)