📄 blob_write_e.c
字号:
/* blob write */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlite3.h>
#define DB_DATA_LENGTH 1024
int main(int argc, char**argv)
{
int ret = 0;
sqlite3 *db = NULL;
sqlite3_stmt * stmt = NULL;
unsigned int* id = malloc(sizeof(int));
const char* name = NULL;
if(argc < 3)
{
printf("Please check enter format(./blob_write_e id name)\n");
return -1;
}
ret = sqlite3_open("test.db", &db);
if (ret != SQLITE_OK)
{
printf("ERROR:: sqlite3_open() failure!\n");
return -1;
}
argv ++;
*id = atoi(*argv);
argv++;
name = *argv;
sqlite3_prepare(db, "INSERT INTO TBL_TEST(ID, NAME) VALUES( ?, ? )", -1, &stmt, NULL);
sqlite3_bind_int(stmt, 1, *id);
sqlite3_bind_blob(stmt, 2, name, strlen(name), NULL);
ret = sqlite3_step(stmt);
if(ret != SQLITE_DONE)
{
printf("ERROR:: sqlite3_step() failure ret is %d!\n", ret);
return -1;
}
sqlite3_finalize(stmt);
sqlite3_close(db);
system("cp test.db ../blob_read");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -