Embed SQLite in Application?

Hey everyone,

I’d like to use a lightweight SQLite database for my game to store some basic information (such as item tables, monster tables, attacks, etc.). However, I’m running into a bit of an issue.

I am using the information found here:

http://forum.unity3d.com/viewtopic.php?t=30249

to work with my SQLite database. I can successfully open up a connection to the database, work with it, etc. And while I can store the database in the Assets fold (and do a file:Assets/database.sqdb connection string) and it works fine while playing in the Editor, once I export the game it seems that the database is not exported, and it is not able to connect.

The only way I’ve been successfully able to get the database to be accessible after build is to put it in the base project directory, and then manually copy it over into the same directory as the executable after the build.

While this works fine for PC (since there is a _data folder anyway that I could figure out a way to make use of, I’m sure), it’s much less convenient for Mac, since everything needs to be stored inside the “App” if possible.

Is there a way to get the SQLite database to be included inside the App/_data folder, and accessible from the built version of the game?

On a side note, it seems based on my limited testing that the SQLite implementation included in Unity does not support the “Password=xxxx” standard for adding basic password-protection. Is there any way to add a password or other form of encryption to the database and still have it accessible to Unity? This is less important then getting it into the App if possible (since if people want to open up the game and modify it that is their choice), but it would be nice to not have the monster, item, attack, etc. tables so easily modified.

Thanks,

RD

do not put the database into the assets folder.

The assets folder, with exception to some special folders (as per U3 Beta5, thats the StreamingAssets folder), will be compressed to what you later find as SharedAssetsXX.dll in your project!

As for “inside App”: app is just a folder like any other. You can right click it - open package and look into it.
the correct place to have it in there is /Contents/xxx, as on the first level you have the Contents directory and the contents directory only

And to get it in there you must do so manually. Potentially a post processing script can help there but potentially you must do it truely manually.

as for the password: Nope at least not on that end. Unity implements nothing there actually, you rely on the mono implementation and mono 1.2.5 had really primarily barebone support for System.Data
Unity 3 will help there with its mono upgrade.

I just did some tests on this, U3B5 does not support the password feature yet on the sqlite databases, I tried both connection strings as follows:

string constr1 = "URI=file:gamedata1.db,Version=3,Compress=True,Password=myPassword";
string constr = "Data Source=gamedata.db;Version=3;Password=myPassword;";

The password was ignored on both, so maybe, just maybe this will make it into U3B6?? No clue. I will probably do a bug report on this later tonight.