Monotouch Sqlite-net or ADO.Net - sqlite

I would like to use Sqlite database in my Monotouch app. From http://docs.xamarin.com/recipes/ios/data/sqlite i see two options.
Sqlite-net
ADO.NET
Doing research i found that Sqlite-net is easy to use, works on both ios and android but does not support foreign key concept. My need is to have relations in my db. Student table is linked to classes, professor, assignments table. Not so complicated!!!
Does Sqlite-net supports such relations? Which one is better choice Sqlite-net or ADO.Net.
Appreciated...
Thanks

ADO.Net doesn't give you out of the box support for relationships either. It only gives you raw classes like SQLCommand and SQLDataReader.
I would highly recommend sqlite-net, as it is a huge timesaver in being an ORM.
You can setup foreign keys by calling manual SQL statements in sqlite-net, which is the same you would do with ADO.Net anyway.
So with sqlite-net, there are several ways you could setup your database:
Call sqlite-net's APIs for creating tables based on your C# classes, then add things it doesn't support with manual SQL like foreign keys and indexes
Include an empty database with your app with the full schema already setup
Create the entire database with a raw SQL script
I tend to go with option #2 if I want full control of the database schema (and it's a little easier to include a database file I made in SQLite Expert). sqlite-net should work with an existing database just fine.

Related

Is it possible to use pure functionality of sqlite-net-pcl and Akavache using it in same project?

In Akavache docs said that it's powered by SQLite.
And from what I heard Akavache is quite nice tool for the key-value storage and sometimes you just don't want to store some cached data into SQL.
Also, usually in mobile apps you also require some data stored in SQL-manner.
In that case it requires two db approaches to be used through the app: SQL and Non-SQL. So, as long as Akavache is still based on SQLite, is there any way to use both: SQLite and Akavache, which uses the sam SQLite (files)?
This is referred in context of Xamarin .NET Standard projects.
Any hints?

How Couchbase Lite use SQlite for NoSQL data

While SQLite is for relationnal database, how couchbase use it for NoSQL data queryable ?
Couchbase Lite can use different storage engines internally.
In the SQLite case, the main document body is stored as a blob. Most of the data in the tables actually has to do with tracking revisions, views, supporting sync (replication), and so on. (This is as of version 1.4.0.)
So, to answer what I think is the main point of your question, CBL isn't turning documents into tables the way you would if you were trying to store the data directly in SQLite.
These are, of course, implementation details you should not rely on. If you're interested in finding out more, you can look at the source (Couchbase is open source) and use standard SQLite tools to examine the database itself.

Python 3 library for working code-first with Sqlite

Is there a Python 3 library that allows working with SQL databases using a code-first approach?
By code-first I understand being able to infer the DB schema from a set of classes and to generate DDL queries to create the DB objects if needed.
I'm particularly interested in working with a Sqlite database.
SQLAlchemy supports Python 3. It also support SQLite, and defining the schema as Python classes, so it seems like the perfect fit for your requirements.

Using ASP.NET tables generated by aspnet_regsql.exe in a SQLite database

I'm building a small ASP.NET MVC site where I want to use SQLite. While I already know how I will be connecting to the database (using DbLinq), I don't understand how to put the ASP.NET tables generated by aspnet_regsql.exe into an SQLite database.
I've used the regsql tool before with SQL Server, but never with SQLite. How do I create them for the SQLite DB?
One strategy that I think might somehow work is:
Use aspnet_regsql.exe to create the tables into an empty SQL Server database
Script all the objects in the database into T-SQL
Apply the T-SQL to the SQLite DB (how?)
Take a look at http://salient.codeplex.com
the Web.SQLite directory contains a drop in replacement for the default SQL providers.
It was a proof of concept that turned out ok. It uses EF, so is not as performant as it could be but should service low/medium traffic sites without issue.
You should be able to exclude all other files except that subdirectory and build it in isolation if desired. This will allow you to also trim the references.
Let me know if you have any issues.
You could try it with SQL Server Compact Edition 4 which is an embeddable SQL engine like SQLite but has an easier upgrade path if you need to grow it up to SQL Express or SQL Server.
Unfortunately the aspnet_regsql will not work with SQLite, so your strategy is essentially the correct approach. However, I would suggest looking at something like Roger Martin's Gallery Server Pro, which uses SQLite and already has the Membership, Role, and Profile provider tables scripted. You can make use of the script. See Roger's Code Project article from more information.

Does sqlite support linq-to-SQL?

Does sqlite support linq-to-SQL?
No database supports LINQ. LINQ is an abstraction layer on top of the database so it depends on the ADO.NET provider. LINQ-to-SQL is also bound to SQL Server.
That being said this SQLLite provider has support for LINQ to Entities.
There's a third-party library called LinqConnect that is aiming at providing Linq-to-SQL support to a variety of database backends - including SQLite.
There's also IQToolkit, which does nothing other than reimplement all of LINQ-to-SQL in open source. This is great if you want "raw" access to your database. IQToolkit Contrib could be handy too if you go this route.
If you're more of an ORM type, you could look at SubSonic (which is built on IQToolkit).

Resources