/***************************************************
> Copyright (C) 2018 ==yangzheng== All rights reserved.
> File Name: mysql.c
# Author: feiren
# mail:512981510@qq.com
> Created Time: 2018年01月15日 星期一 15时05分51秒
***************************************************/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <pthread.h>
#include <semaphore.h>
int main(int argc,const char* argv[])
{
char buf[128] = {0};
FILE *fp = fopen("./msg.sql","w+");
if(NULL == fp){
perror("fopen");
return -1;
}
fputs("PRAGMA foreign_keys=OFF;\n",fp);
fputs("BEGIN TRANSACTION;\n",fp);
fputs("CREATE TABLE user ( id INTEGER PRIMARY KEY AUTOINCREMENT, name text , pass text);\n",fp);
fputs("COMMIT;\n",fp);
fclose(fp);
return 0;
}
通过C语言创建sql脚本文件,利用sqlite3 xxx.db < xxx.sql 生成xxx.db
最新推荐文章于 2023-02-08 15:42:15 发布