No DLL, only C# code! So, no headache with cross-platform support!
Helps organize statistics or score in one single database file to enjoy sophisticated search using SQL language and benefits of keeping everything in one place.
All platforms are supported as long as it is just a pure C# library. Tested on WebGL, IPhone, Android, PC and Mac.
It can be used for game scenarios or settings storage which could be easily modified by great tools like SQLite Database Browser.
Best advantage is that you can read or download database file into memory, which is crucially important for platforms like WebPlayer where access to the file system is restricted because of security reasons.
UTF8 and BLOB supported and tested.
true SQLite file format.
SQLite API nicely wrapped in C#.
example code:
// database file name.
//
string filename = Application.persistentDataPath + "/demo.db";
// create database object
//
SQLiteDB db = new SQLiteDB();
// initialize database
//
db.Open(filename);
// make a query object
//
SQLiteQuery qr = new SQLiteQuery(db, "SELECT * FROM test_values;");
// read result
//
while( qr.Step() )
{
string astring = qr.GetString("str_field");
byte[] ablob = qr.GetBlob("blob_field");
}
// release query object
//
qr.Release();
// close database
//
db.Close();
I sent you an e-mail, but I figured this would be a good question for the boards.
What dependencies does this kit have on the .NET API? It seems you can’t strip or use the subset, which is pretty painful in terms of build size and to me, is a pretty big downside.
I just tried this using Unity 3.5.6f4 (iOS Pro) and I was able to get it to run on the device with stripping and .Net 2.0 subset. The only problem I ran into was when I tried to use micro mscorelib which results in the following:
UnityException: Failed assemblies stripper: /Applications/Unity/Unity.app/Contents/Frameworks/Mono/bin/mono "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedBytecodeStripper/UnusedBytecodeStripper.exe" -l none -c link -a "Assembly-CSharp.dll" -out output -x "/Applications/Unity/Unity.app/Contents/Frameworks/Tools/UnusedBytecodeStripper/link.xml" -d "Temp/StagingArea/Data/Managed" -x "tmplink.xml" current dir : Temp/StagingArea/Data/Managed
result file exists: False
stdout:
stderr: Unhandled Exception: Mono.Linker.ResolutionException: Can not resolve reference: System.Boolean System.Threading.WaitHandle::WaitOne(System.Int32) at Mono.Linker.Steps.MarkStep.MarkMethod (Mono.Cecil.MethodReference reference, System.Object markedby) [0x00000] in <filename unknown>:0 at Mono.Linker.Steps.MarkStep.MarkInstruction (Mono.Cecil.Cil.Instruction instruction, Mono.Cecil.MethodDefinition markedby) [0x00000] in <filename unknown>:0 at Mono.Linker.Steps.MarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x00000] in <filename unknown>:0 at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0 at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00000] in <filename unknown>:0 at Mono.Linker.Steps.MarkStep.Process () [0x00000] in <filename unknown>:0 at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0 at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in <filename unknown>:0 at UnusedBytecodeStripper.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
UnityEditor.MonoProcessUtility.RunMonoProcess (System.Diagnostics.Process process, System.String name, System.String resultingFile)
UnityEditor.MonoAssemblyStripping.MonoLink (BuildTarget buildTarget, System.String managedLibrariesDirectory, System.String[] input, System.String[] allAssemblies, UnityEditor.RuntimeClassRegistry usedClasses)
UnityEditor.HostView:OnGUI()
Thanks for the fast reply and e-mails late last night Oksana, and kenlem that is definitely good news!
I have another question. I’m currently using the MemoryStream method of accessing my database from the streaming assets folder. All I’m doing on Awake() of one of my scripts is opening the DB connection, and then running 9 GetDouble queries and 1 GetInteger query, but it seems like this takes 6 seconds for some reason. It doesn’t seem like there’s enough Debug output from our plug-in to really get an in-depth look.
So is this normal? Or am I most likely doing something wrong. This is for Android btw.
Hello dannyskim, I submitted version 1.4 to assetstore with full code, so I will fix problem with Android, I notes that unity is really bad with dll on android, since i have no problem anywhere else. The delay happens because i do dll delay load. so please email me I’ll send Version 1.4, asset store is delay to publish last version.
Thanks
To answer my own question, under “Build Settings”, select “Player Settings”, then in the Inspector window in the Unity IDE, select the iOS target, then under “Other Settings” set “Stripping Level” to “Disabled”.
Hi, I’ve just bought your SQLite3 plugin for my Unity3D Pro but I have problems with the queries. “SELECT” command works perfectly but the queries with the “UPDATE” and “DELETE” command don’t work at all, even they are working perfectly in the command line. I think all I need to do is:
SQLiteQuery query = new SQLiteQuery(Db, “UPDATE …”);
query.Step();
query.Release();
It is working in the command line in windows and in the navigators for the SQL. But it’s not working in the game. How can fix this? Thanks in advance…
Hello, first off, is there any other places we can ask for help / support other than here?
2nd - How does working with aggregate queries work? I tried SELECT MAX(dbfield) FROM table; and I got an exception. It looks like the class iterates through each field in the query by splitting on the word SELECT and commas? Please advise.
regarding 2 question, i guess it doesn’t - please send me more information, because it should works if your table has “dbfield”
Mainly you could try your query with SQLiteDatabaseBrowser to see the errors and replay as long as it use the same dll,
Exactly , it simulate file system for sqlite library in memory, so in fact you have bynary byte stream which is reflect real sqlite3 format file, so you could download and upload back to the server as regular file.
Hi i bought your plugin, and seem to be a great plugin, but haven’t tested exhaustively, just two questions how can i get the number of rows the query returns? and second when i save the db which the size is 2mb on the persistent data path from the streamingAssets, the db is backup on icloud, and apple will not approve my app, so how can i prevent that the db is backup on icloud.
Sqlite library doesn’t support receiving number of rows from query.there is the reason - sqlite don’t read all records in memory but execute by steps. So they just don’t have it. But if you need a count you could use request like this: select count(*) as count from table where…
For second question if you have read-only data you may load database in to memory each time, so you will not have a file at all, plus that be works on webplayer automatically.