wordpress网站源代码,怎么提升网站的流量吗,东莞网站建设0086,营销渠道方案一#xff1a;让 SQLiteExpert 支持#xff08;cipher#xff09;加密数据库 SQLiteExpert 作为SQlite 的管理工具#xff0c;默认不支持加密数据库的#xff0c;使其成为支持#xff08;cipher#xff09;加密数据库的管理工具#xff0c;需要添加e_sqlcipher.dll 让 SQLiteExpert 支持cipher加密数据库 SQLiteExpert 作为SQlite 的管理工具默认不支持加密数据库的使其成为支持cipher加密数据库的管理工具需要添加e_sqlcipher.dll 复制到SQLiteExpertPro32/64.exe 同级目录即可从哪里来的这个问题你可以直接往后面下载链接下也可以跟随文章知道从哪里来的。最好是知道从哪里来的也许我放链接的版本在未来有新版本更替我也就不更新下载链接了。并在其设置里面进行勾选就能激活加密数据库支持。如下图所示(几个关键点已经标记)需要注意的是SQLiteExpert 32位/64位需要与e_sqlcipher.dll 32位/64位匹配否则在32位版的SQLiteExpert 是看不到64位的e_sqlcipher.dll。
加入成功后打开或者新建数据库都有加密选项 新建数据库 打开加密数据库 这样到此可以完整的处理了SQLiteExpert 支持加密 由于SQLiteExpert 只有windows 版本linux 平台的cipher加密支持库也就不打包了。对于跨平台的SQLite gui 也许类似上传的压缩包就只有windows平台dll。
下载链接在顶部压缩包结构如下 二. .Net C# 连接cipher加密的SQlite数据库
nuget
1、SQLitePCLRaw.bundle_e_sqlcipher
2、Microsoft.Data.Sqlite
3、Costura.Fody 如果不需要考虑发布洁癖单文件全部外围DLL聚合就没必要。
直接debug生成一堆内容我随便建立了个VS 工程sqlitedemo debug目录大致如下 runtime 内容如下也就是各种平台的ciphersqlite lib前面的e_sqlcipher.dll取材就是从这里取得。 debug 生成的很多也就是刚才说的发布生成洁癖的问题如果你在意发布时候选择输出好平台runtime可以自动减少但是依旧会生成其他dll。
那就采用Costura.Fody
编辑项目内 FodyWeavers.xml 文件nuget过了会自动生成该文件文件内容修改如下
Weavers xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocationFodyWeavers.xsdCostura Unmanaged64Assembliese_sqlciphere_sqlite3/Unmanaged64AssembliesUnmanaged32Assembliese_sqlciphere_sqlite3/Unmanaged32Assemblies/Costura
/Weavers
再编辑 解决方案文件右边第一箭头那里双击 主要语句加入 我选择的x64版本的Exe RuntimeIdentifierwin-x64/RuntimeIdentifier 这样右键点击 解决方案-重新生成解决方案 (这里要注意要重新整个解决方案才行。更改解决方案文件直接debug会有问题。) 最终生成输出内容如下 其他乱七八糟的dll没有了清爽吧
再来看相关C# 连接Sqlite 操作的代码先上SqliteHelper顺便也推荐一下 Cody AI生成的我用了很长时间免费且好用面向编程。 public class SQLiteHelper{private readonly string _connectionString;public SQLiteHelper(string dbPath, string password null){var builder new SqliteConnectionStringBuilder{DataSource dbPath,Mode SqliteOpenMode.ReadWriteCreate};if (!string.IsNullOrEmpty(password)){builder.Password password;}_connectionString builder.ConnectionString;}public int ExecuteNonQuery(string sql, ListSqliteParameter parameters null){using (var connection new SqliteConnection(_connectionString)){connection.Open();using (var command connection.CreateCommand()){command.CommandText sql;if (parameters ! null){command.Parameters.AddRange(parameters);}return command.ExecuteNonQuery();}}}public T ExecuteScalarT(string sql, ListSqliteParameter parameters null){using (var connection new SqliteConnection(_connectionString)){connection.Open();using (var command connection.CreateCommand()){command.CommandText sql;if (parameters ! null){command.Parameters.AddRange(parameters);}var result command.ExecuteScalar();return (T)Convert.ChangeType(result, typeof(T));}}}public ListT ExecuteQueryT(string sql, ListSqliteParameter parameters null) where T : new(){var result new ListT();using (var connection new SqliteConnection(_connectionString)){connection.Open();using (var command connection.CreateCommand()){command.CommandText sql;if (parameters ! null){command.Parameters.AddRange(parameters);}using (var reader command.ExecuteReader()){while (reader.Read()){var item new T();for (int i 0; i reader.FieldCount; i){var property typeof(T).GetProperty(reader.GetName(i), BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);if (property ! null !reader.IsDBNull(i)){property.SetValue(item, Convert.ChangeType(reader.GetValue(i), property.PropertyType));}}result.Add(item);}}}}return result;}public void ExecuteTransaction(ActionSqliteConnection action){using (var connection new SqliteConnection(_connectionString)){connection.Open();using (var transaction connection.BeginTransaction()){try{action(connection);transaction.Commit();}catch{transaction.Rollback();throw;}}}}}
}
调用如下
SQLiteHelper 构造函数第一个参数数据库路径文件全名第二个参数数据库密码 SQLiteHelper SLH new SQLiteHelper(D:\\Manage\\Documents\\db, TEST);const int batchSize 100000;const string insertSql INSERT INTO Student (F_ID, F_Name) VALUES (F_ID, F_Name);SLH.ExecuteTransaction(connection {using var command connection.CreateCommand();command.CommandText insertSql;command.Parameters.Add(F_ID, SqliteType.Text);command.Parameters.Add(F_Name, SqliteType.Text);for (int i 0; i batchSize; i){command.Parameters[F_ID].Value Guid.NewGuid().ToString();command.Parameters[F_Name].Value $John{i};command.ExecuteNonQuery();}});
密码错误则在这里报错 这样既可以C# 开发加密数据库又可以在外部用外部工具直接编辑加密数据库的环境就达成了。
后话 选择SQLiteExpert 是界面要黑一点可能不是最好用的但黑色看起来眼睛舒服一点欢迎推荐一些。