Using Sqlite for iPhone build

I've seen a few posts regarding using Sqlite in Unity, though nothing I try seems to work. Either some basic info is missing from the posts or I'm just doing something wrong. If I do this, as many posts suggest:

import System;
import Mono.Data.Sqlite;

I still get an error message in the compiler:

Namespace 'Mono.Data.Sqlite' not found, maybe you forgot to add an assembly reference?

Assuming that someone can help me get around that basic problem, let's say I want to use Sqlite databases since I plan to publish to iPhone, and iPhone supports Sqlite natively. Is there anything special I need to do? Basically, I use one read-only db for storing game metadata, and one writable db for storing save games.

hi, you can use this code its easy to use and its free for your individual use,

use example:

SqliteDatabase sqlDB = new SqliteDatabase(“config.db”);
string query = “INSERT INTO User(UserName) VALUES( ‘Santiago’)”;
sqlDB.ExecuteNonQuery(query);

its so easy… the file “config.db” is necessary exist in the “StreamingAssets” folder

i hate the people who sell this things in the assets store, something easy like this… we need more open sources users :slight_smile:

link — > click here to download

link — > GitHub Repository

works on iOS, MAC OSX, Windows, i dont sure if works on web and android, if you test in that OS tell me the result… thanks

you just need to copy Mono.Data.Sqlite.dll(and maybe System.Data.dll) to Assets/Plugins folder. Hope it helps.

You might want to use this pure managed code version of SQLite. However keep in mind this .NET port is not an official version by the original author of SQLite.

I haven’t tested it yet but since it’s 100% managed code it should run on any platform (except webplayer of course)

you could try SQLiteKit from asset store - it not requere any dependency and works on all platforms including WebPlayer

Well SQLIte4Unity3d plugin does all the work for you.

This video will make it more clear.

http://neeracademy.com/app-development-tips/support-sqlite-unity-app-episode-11/

I hope this helps.

Hello everyone,

I’m trying to connect to a db.sqlite with basic unity and a IOS license to develop an app for the iphone 4.

I created my db (name.sqlite) and I put this file out of the Assets folder. Then I took the two dll (Mono.Data.SqliteClient.dll and System.Data.dll) and I put this file out of the Assets folder.

In my code (JavaScript) I do the following imports:

  • import System.Data;
    
  • import Mono.Data.SqliteClient;
    

When I try to build this code for iOS platform:

import System.Data;
import Mono.Data.SqliteClient;

private var connectionString: String;
private var dbcon : SqliteConnection; //the instantiation of this creates errors
...
...

this generated the following error:

ArgumentException: The Assembly Mono.Data.SqliteClient is referenced by Assembly-UnityScript. But the dll is not allowed to be included or could not be found.

  • Error building Player: Extracting referenced dlls failed.
    
  • Exception: Error building Player: Extracting referenced dlls failed.
    

Why???

My friend,

you’ll need to write a plugin for iOS if you want to use Coccoa’s native SQLite as you say it is your intention. The asset below does that for a commercial price. It will also allow to build for any platform with the same single c# code in Mono Develop. It is salty but worthwhile.