https://www.assetstore.unity3d.com/jp/#!/content/3845
無料の SQLiteUnityKit もあるのですが、
更新が止まっていることと、自分でカスタマイズできるものの色々と
手間がかかるしややこしいという点から、アセットを購入することにしました。
ですが、日本語をINSERTしようとしたときにエラーが出てしまいました。
"Insert" を使った場合:
-------------------------------------------
SQLiteException: Constraint
SimpleSQL.PreparedSqlLiteInsertCommand.ExecuteNonQuery (System.Object[] source)
SimpleSQL.SQLiteConnection.Insert (System.Object obj, System.String extra, System.Type objType, System.Int64& rowID)
SimpleSQL.SQLiteConnection.Insert (System.Object obj, System.Int64& rowID)
SimpleSQL.SimpleSQLManager.Insert (System.Object obj, System.Int64& rowID)
SimpleSQL.SimpleSQLManager.Insert (System.Object obj)
-------------------------------------------
"Execute" を使った場合:
-------------------------------------------
SQLiteException: unrecognized token: "'20"
SimpleSQL.SQLite3.Prepare2 (IntPtr db, System.String query)
SimpleSQL.SQLiteCommand.Prepare ()
SimpleSQL.SQLiteCommand.ExecuteNonQuery ()
SimpleSQL.SQLiteConnection.Execute (System.String query, System.Object[] args)
SimpleSQL.SimpleSQLManager.Execute (System.String query, System.Object[] args)
-------------------------------------------
サポートに問い合わせたら、SQL内で日本語を記述するところに「?」を書き、
Execute()の第2引数以降で渡せばよいと回答がありました。
フォーラムに過去のやりとりが記載されていました。
http://www.echo17.com/forum/index.php?topic=257.msg399#msg399
例)
SimpleSQL.SimpleSQLManager dbManager;
// ゲームオブジェクトにSimpleSQLManagerが適用されていること
dbManager = this.GetComponent
string query = "INSERT INTO TEST(name) values(?)";
dbManager.Execute(query, "テスト");
これで無事、日本語を扱うことができるようになりました。