Moving from SQLte to Realm - sqlite

I have a working app that uses SQLite as DB. I would like to move to Realm DB. Will this affect my existing users? How do I move over to Realm? My app is developed in Xamarin.

When you have created your schema, you need to iterate your sql values and add data in realm, for example(you need convert java to C#):
for (SqlTest sqlData : sqlTest) {
Test test1 = realm.createObject(Test.class, UUID.randomUUID());
test1.setName(sqlData.getName());
test1.setSex(sqlData.getSex());
}

Related

How to backup Sqlite database if sqliteOpenHelper class is used

I'm quite new in c# and Xamarin android and I want to backup and restore my offline SQLite database created with sqliteOpenHelper Class, send and use that on another device. thanks in advance.
In Android API sets, the providers for SQLite library are available under, android.database.sqlite package. The most prominent types in the package are:
1. SQLiteOpenHelper: This is the main class that you need to inherit your classes from, in order to handle the database creation, opening or closing events. Even the events such as create new tables, or deleting the old tables and upgrading your databases to a latest version (such as upgrading the schema), are all handled here in this class-derived classes of yours.
2. SQLiteDatabase: This is the object that you get and use to either push the data to the database, or to read the data from the database.
3. SQLiteCursor: This is the cursor implementation for working with the data records that are returned after Query commands.
The way they all communicate is that, the main class for the data manipulation first of all inherits from SQLiteOpenHelperto get the functions to handle, then later has a field of type SQLiteDatabasein it to execute the functions for writing or reading the data.
For more information, you can check:
https://basicsofwebdevelopment.wordpress.com/2017/02/19/learning-sqlite-databases-in-xamarin-for-android/
https://www.c-sharpcorner.com/article/xamarin-android-develop-sqlite-database-using-sqliteopenhelper/

Change the database in Microstrategy Intelligent Cube

How to change the database of an already created Intelligent Cube in Microstrategy?
I have a cube which is getting data from Tables in production.
We have same tables in other database as well.
Is there any way i can modify the cube to use the new database?
You cannot modify just your cube to point to a different database if it was not create as a FFSQL report (in that case it's easy, you just change the database instance used), but you have a couple of options:
Modify the database connection setting for the database instance used by your project. My suggestion is to create a new database connection for the other database and point the current instance to this new connection
Create a new database instance (if you don't have it already) and assign it as default one to your project. Not sure it the existing tables will be mapped to the new one automatically.
Create a new database instance (like above), open the Warehouse catalog and change the database instance for the tables used in the cube.
Sincerely I would go for the first option if the other database contains all the tables required by your project.

SQLite data cleanup in Windows 8 application

In my windows 8.1 application i am using SQLitePCL on top of SQLite.
I create the tables and populate my test data on application launch.
I only create DB tables if the tables are not existing through SQL is exists keyword in the queries.
Now how do i clean up the populated test data. Do i have to run delete queries when application shuts down ?.
I am testing through Windows simulator 8. Is there no way to clean up the app data which will flush the db in the simulator ?
cheers,
Saurav
I suggest you to recreate DB schema every time you need to flush populated data. You have at least two options to achieve that:
At first: in the same way as you create DB tables if they are not exist, you can delete DB when the data should be flushed and recreate it. I use this code to open/create DB file.
private async Task<bool> IsDBExistAsync()
{
bool isExist = true;
try
{
StorageFile sf = await ApplicationData.Current.LocalFolder.GetFileAsync(DATABASE_NAME);
}
catch (Exception)
{
isExist = false;
}
return isExist;
}
At second: open explorer window and navigate to C:\Users\{username}\AppData\Local\Packages\{package_family_name}\LocalState and delete DB file manually when it is not needed anymore. "package_family_name" is specified in Package.appxmanifest of your app (Packaging tab).
Bonus item: if you are developing phone part - you can access local storage using Windows Phone Power Tools utility.

How to do concurrent read & write on SQLite database?

I am creating a Windows Store application, which takes a lot of data from web service daily and then insert/update data to SQLite. So the user has to wait till the data is downloaded to SQLite database then he is redirected to other screen whcih shows that downloaded data in user friendly manner.
Is it possible to run the downloading & database operations in background and user can use the app ? I tried to combine the downloading & insertion operations & UI of showing the data in single page but I am getting error "database is locked". If my app is suspended, will database insertion/update & web service call work in background ?
PS : I am using sqlite-net
You can do a number of inserts in a single transaction, like so
using (SQLiteConnection db = new SQLiteConnection("[database path]"))
{
db.RunInTransaction(() =>
{
db.Insert(MyClass);
});
}
This should prevent database locking.

Retrieving Data from the Database ASP.NET MVC + Oracle

I have two tables
Users (Userid, Name, PhoneNumber)
Applications (ApplicationsId,UserId, ApplicationName, ActiveDate)
Every user will have more than 1 application.
In Nhibernate using lazy loading I can get the users data along with all the applications for every user. So, I used to do something like user.applications[i].Applicationname to get all the applications.
But, Now how do i retrieve all the applications along with the users data using oracle commands. I know how to get one application using joins. But, how do i retrieve multiple applications and store it in a IList. Any help is greatly appreciated. Thank you.
First you should download the Oracle Data Provider for .NET in
http://www.oracle.com/technology/tech/windows/odpnet/index.html
after you make sure that you can open a connection to your oracle database then
define mapping file of your entities in Nhibernate and map table columns of your oracle table to .NET object. after that you can use the following code snippet to get the list of your entity from database
// create the query...
IQuery query = session.CreateQuery( "from Post p where p.Blog.Author = :author" );
// set the parameters...
query.SetString("author", (String) instance);
// fetch the results...
IList results = query.List();
You should define the (Post) entity and (Blog) entity to your mapping file and as you can see (Post) has relation to (Blog) entity which is defined in the mapping file too.

Resources