Best SQLite.net PCL to use with Xamarin?

I'm new to this and was wondering what's the best SQLite.net PCL to use? My solution consists of 3 different projects: WP, IOS and Android version. The only thing these 3 projects share are the PCL files (UI will be separate for each one). I've found SQLite.Net PCL via NuGet visual studio, but am haven't a hard time finding documents for it. Is this the best PCL to go with or there are better recommend ones?

Posts

  • LoriLalondeLoriLalonde CAInsider, University, Developer Group Leader ✭✭✭

    The SQLite-net PCL by Frank Kreuger is the one that Xamarin University uses in their XAM160 - Working with SQLite and Mobile Data class: https://university.xamarin.com/classes/track/cross-platform-design

    You can find some documentation on how to get started on the Xamarin developer site: http://developer.xamarin.com/recipes/android/data/databases/sqlite/

  • SilverSurferSilverSurfer USMember ✭✭

    I noticed there are a few SQLite via nuget

    SQLite.net-PCL
    SQLite-net PCL
    SQLite.net-PCL async

    I was able to find some documents by clicking on the link id of the author site page. It appears the majority of people downloaded SQLite.net-PCL and I understand this is only Synchronous. This may be okay for the apps, but I will probably go with SQLite.net-PCL async.

    Thanks for the response!

  • JamesMontemagnoJamesMontemagno USForum Administrator, Xamarin Team, Developer Group Leader Xamurai

    I recommend using the official from Frank: https://www.nuget.org/packages/sqlite-net-pcl/

    I just did a live coding session on this:

  • dpedrinhadpedrinha DEMember ✭✭✭

    What about the other plugin from the same author called SQLite.Net-PCL?

    There are two: SQLite.Net-PCL and sqlite-net-pcl

    Both from Frank.

    What's the difference between them?

  • GuyProvostGuyProvost CAMember ✭✭✭

    @dpedrinha said:
    What about the other plugin from the same author called SQLite.Net-PCL?

    There are two: SQLite.Net-PCL and sqlite-net-pcl

    Both from Frank.

    What's the difference between them?

    Man.... Would I like to have the answer on this one. We use the SQLite.Net-PCL cause we use another package over it (extensions) that depend on it in order to have cascading. Now, with the Nougat NDK limitation, we are kinda screwed!

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    Clicking through to Frank's github site, he has only one package: SQLite-net PCL. The link provided by @JamesMontemagno is the link to Frank's only SQLite package. It's a fork from Koushik Dutta's sqlite-net package.

    Frank's is being maintained. Koushik's hasn't been updated in 3 years.

  • GuyProvostGuyProvost CAMember ✭✭✭

    @DaveHunt said:
    Clicking through to Frank's github site, he has only one package: SQLite-net PCL. The link provided by @JamesMontemagno is the link to Frank's only SQLite package. It's a fork from Koushik Dutta's sqlite-net package.

    Frank's is being maintained. Koushik's hasn't been updated in 3 years.

    So I guess that either I port the SQLite PCL Extension (fun to have cascading out of the box) or do the data queries the old way ?

    Thanks for the info!

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    @GuyProvost

    According to the SQLite-Net Extensions site, the preferred base is the SQLite-Net PCL nuget package James referenced. Unless that's not the extensions package you're talking about, there should be no problem.

  • dpedrinhadpedrinha DEMember ✭✭✭

    I'm having problems with my static database using SQLite-Net PCL nuget package. After a while, the database starts failing and the app won't open anymore unless the user uninstall it and install again. My workaround was to force the app to recreate the database every time the user opens it. Which makes the launch take longer and of course, consumes more battery. Not a good behavior but neither Xamarin team or Frank won't reply to me.~
    I've a bug filled here: https://bugzilla.xamarin.com/show_bug.cgi?id=42822

  • RodyRody USMember ✭✭

    Another good reason to go with sqlite-net-pcl instead of sqlite.net-pcl, is because the Automatic Migration in sqlite.net-pcl is broken. This is a big deal. What it does is when you update your models, the associated table will be modified to work with the modified model, after calling CreateTable or CreateTableAsync.

    A search on the Github site for sqlite.net-pcl shows that this bug was reported two years ago, but has not been fixed.

  • GerryHighGerryHigh USBeta ✭✭✭
    edited September 2016

    @dpedrinha that bugzilla must be marked Xamarin only? I got "You are not authorized to access bug #42822."

    I'm using Frank's SQLite PCL as well (https://www.nuget.org/packages/sqlite-net-pcl/) and I'm seeing some weird stuff in iOS 10 where it seems like the database is blank suddenly (e.g. do a select on one page, navigate to another page, select, returns nothing). I haven't tracked it down yet as to the pattern or what is causing it.

  • dpedrinhadpedrinha DEMember ✭✭✭

    @GerryHigh said:
    @dpedrinha that bugzilla must be marked Xamarin only? I got "You are not authorized to access bug #42822."

    I'm using Frank's SQLite PCL as well (https://www.nuget.org/packages/sqlite-net-pcl/) and I'm seeing some weird stuff in iOS 10 where it seems like the database is blank suddenly (e.g. do a select on one page, navigate to another page, select, returns nothing). I haven't tracked it down yet as to the pattern or what is causing it.

    Yes, sorry, It's marked to the devs only. It has some sensitive data. Forgot about that.

    I'm not sure what is going on in my case, because it happened to my released version on the user's devices only, never happened in my devices. All I know is that the App closes at launching. And the bug stopped when I forced the DB to be created every time the App is launched.

    If you fill an open bug, please share here so I can reinforce the issue.

  • tntwisttntwist USMember ✭✭

    I'm also having problems with Frank's SQLite PCL.
    My app crashes during every launch, because of Exceptions like this SQLite.SQLiteException: duplicate column name: StreetName.
    This exceptions only occurs for release builds with linking options set to : link all assemblies. With just linking SDKs assemblies i don't get them but with the updated version v1.2.0 of the lib, my database is empty :(.

    Well good for me the app hasn't been rolled out to customers yet.

    Any suggestions how i could at least fix the exceptions?

  • dpedrinhadpedrinha DEMember ✭✭✭

    Try to contact the plug-in creator. I tried, not success. But maybe if more people do he will start looking into that problem.

  • tntwisttntwist USMember ✭✭

    I could fix the exceptions with skipping the library at linking for release builds.

    After some testing I recognized that my db isn't really empty. I use a search bar with an table view for suggestions. It seems the table view is not being updated correctly when compiling with iOS 10 SDK and no suggestions are displayed.

  • dpedrinhadpedrinha DEMember ✭✭✭

    @tntwist said:
    I could fix the exceptions with skipping the library at linking for release builds.

    After some testing I recognized that my db isn't really empty. I use a search bar with an table view for suggestions. It seems the table view is not being updated correctly when compiling with iOS 10 SDK and no suggestions are displayed.

    Then it looks your problem is different than mine. My DB is static, and pretty big. The problem is not on release, but on released versions after some use. The DB never changes, it's like a dictionary. But after some use, many users started having issues where the app would crash on launch. I couldn't reproduce it so I can't test it. And of course, I can't risk testing it on released versions. So I'm kinda stuck until the dev tells me that he found the issue and fixed it. My workaround was to recreate the DB on everylaunch. Not optimal, but it's working.

  • PhillWigginsPhillWiggins USMember

    @dpedrinha @tntwist

    Did anyone solve this. I'm having similar issues and cannot fix them at all?

  • dpedrinhadpedrinha DEMember ✭✭✭

    @PhillWiggins I need to force the recreation of the database every time the app is started. Definitely not the best approach, but... This bug is being ignored by the devs. My bugzilla about it was closed. I have the feeling I'm the only one using SQLite with Xamarin. I can't believe there isn't a bunch of other people with the same problem.

  • JohnMurrayJohnMurray GBMember ✭✭

    Just to add my 5 pennyworth which may help someone else (I spend most of my time (albeit partime programmer) trying to find workarounds for issues with Xamarin arghhh and precious little time developing ) whinge over
    No not quite - the various SQLite offerings are impressive an I am sure I couldn't provide something as useful in a million years but pleeeeese guys why call the offers such similar names SQLite.net-PCL and SQLite-net-pcl then refer to the latter in documentation as SQLite-net PCL (without hyphen capitalised) Almost designed to confuse

    Anyway through a process of time consuming trial and error I've found 1.3 of sqlite-net-pcl dated Jan 2017 doesn't work with my Android/Ios/UWP - it requires me to downgrade to 1.2.1 and even then it doesn't work with UWP because some dependencies are not compatible with UAP 10 - so downgraded the UWP project to 1.1.2 and hey presto everything works

    Ah well back to a normal day working(groping around) with Xamarin - now where's my white stick ;-)

  • dpedrinhadpedrinha DEMember ✭✭✭

    So now we have a new problem. When upgrading SQLite-net-pcl we need to install another 40+ dependency packages. And it's always throwing errors. Sometimes those packages are installed only in Android, sometimes in Android and iOS, but never into PCL or UWP.
    It's just not working since version 1.3.0 and now 1.3.1.
    1.2.1 works but with the problems above.
    Is there any other option?

  • MarkZhukovskyMarkZhukovsky USMember ✭✭

    @GuyProvost and others that were using SQLite.Net-PCL and found that Android API 24+ didn't take kindly to it: for my app was easy to make all things right again by following these steps:
    1) install Mono.Data.Sqlite.Portable and SQLite.Net.Platform.XamarinAndroidN nuget packages to your Android project
    2) replace all your SQLitePlatformAndroid objects with SQLitePlatformAndroidN

    Hope this helps.

  • hi,
    please one help for me.
    why cant passed argument in SQLiteConnection,Actually i created

    public SQLiteConnection GetConnection()
    {
    SQLiteConnection con;
    var sqliteFilename = "Employee.db3";
    IFolder folder = FileSystem.Current.LocalStorage;
    string path = PortablePath.Combine(folder.Path.ToString(), sqliteFilename);
    con = new SQLiteConnection(path);
    return con;
    }

    but con=new SQLiteConnection(path) this line error occur.
    please reply me.

  • Why Xamarin has no support SQL implementation is beyond frustrating. A large portion of Xamarin's success rests on this one Nuget package and one developer maintaining it...

Sign In or Register to comment.