sqlite3数据库的简单介绍
本篇文章给大家谈谈sqlite3数据库,以及对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
sqlite3数据库怎么存储数组类型
/*思路是敏拿则把数组保存成blob格式
#include stdio.h
#include stdlib.h
#include string.h
#include "sqlite3.h"
/*#define DEBUG*/
int main(int argc, char *argv[]) {
int a[10] = {1,3,8,4,6,6,7,8,9};
int len;
len = sizeof(a[0])*10;
#ifdef DEBUG
printf("%d\n"敏带,len);
#endif
sqlite3 *db;
sqlite3_stmt *stmt;
char *sql,*zErr;
int rc;
rc = sqlite3_open_v2(":memory:",db,SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE,NULL);
if(rc){
fprintf(stderr,"%s\n"桥棚,sqlite3_errmsg(db));
return rc;
}
rc = sqlite3_exec(db,"create table if not exists test(array blob);",NULL,NULL,zErr);
if(rc != SQLITE_OK){
fprintf(stderr,"%s\n",zErr);
sqlite3_free(zErr);
sqlite3_close(db);
return rc;
}
sql = "insert into test values(?);";
sqlite3_prepare_v2(db,sql,strlen(sql),stmt,NULL);
sqlite3_bind_blob(stmt,1,a,len,SQLITE_STATIC);
sqlite3_step(stmt);
sqlite3_reset(stmt);
sql = "select * from test;";
sqlite3_prepare_v2(db,sql,strlen(sql),stmt,NULL);
sqlite3_step(stmt);
len = sqlite3_column_bytes(stmt,0);
int *data = malloc(len);
memcpy(data,sqlite3_column_blob(stmt,0),len);
sqlite3_finalize(stmt);
sqlite3_close(db);
#ifdef DEBUG
printf("%d\n",sizeof(a[0]));
#endif
int i = 0;
while(i(len/sizeof(a[0]))){
printf("a=%d, data=%d\n",a[i],*(data+i));
i++;
}
system("pause");
return 0;
}
SQLITE3 如何打开.db的数据库文件查看文件内容
1、打开程序后,可以看到程序左边的“数据库列表”。展开可以查看到所有打开过的数据库。
2、 点击一个.db文件,把这个.db直接拖拉进程序窗口。
3、显示“吵蚂芹注册数据库”,点击【确定】,这样就可以用 SQLiteDeveloper管理这个.db文件了。
4、 展开左边数据库列表,找到刚才注册的.db文件。点击右键菜单的【打开数据库】。
5、打开数据库后可以看到这个.db文件中有很多的数据表物中,选择其中一个,右键点击【查询数据】。则可以查看这个表的数据内容。
6、 数据库看完后记得【关闭数据库】。否则这个.db文件公被程序占用不能移动与删升毕除。
[img]如何对sqlite3数据库进行加密
给SQLite数据库加密解密的方法:
1、创建空的sqlite数据宽汪库。
//数据库名的后缀你可以直接指定,甚至没有后缀都可以
//方法一:创建一个空sqlite数据库,用IO的方式
FileStream fs = File.Create(“c:\\test.db“);
//方法二:用SQLiteConnection
SQLiteConnection.CreateFile(“c:\\test.db“);
创建的数据库是个0字节的文件。
2、创建加密的空sqlite数据库
//创建没虚一个密码为password的空的sqlite数据库
SQLiteConnection.CreateFile(“c:\\test2.db“);
SQLiteConnection cnn = new SQLiteConnection(“Data Source=c:\\test2.db“);
SQLiteConnection cnn = new SQLiteConnection(“Data Source=D:\\test2.db“);
cnn.Open();
cnn.ChangePassword(“password“);
3、给未加密的数据库加密
SQLiteConnection cnn = new SQLiteConnection(“Data Source=c:\\test.db“);
cnn.Open();
cnn.ChangePassword(“password“);
4、打开加密sqlite数据库
//方法一
SQLiteConnection cnn = new SQLiteConnection(“Data Source=c:\\test2.db“);
cnn.SetPassword(“password“);
cnn.Open();
//方法二
SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
builder.DataSource = @”c:\test.db“;
builder.Password = @”password“;
SQLiteConnection cnn = new SQLiteConnection(builder.ConnectionString);
cnn .Open();
除了用上述方法给SQLite数据库加密以外,您还可以使用专业的文件加密软件将SQLite数据库加密。
超级加密 3000采用先进的加密算法,使你的文件和文件夹加密后,真正的达到超高的加密强度,让你的加密数据无懈可慎察仔击。
超级加密3000使用起来,只要点击需要加密的文件的右键,即可轻松实现文件的加密。
解密只要双击已加密文件,输入密码即可轻松搞定。
关于sqlite3数据库和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。