0

I have a lengthy SQL INSERT command that I would essentially like to convert to a local Xamarin database, using SQLite. Is there any easy way around this or do I manually have to create an object from each value which is then entered into the local SQLite database?

4
  • do you mean a one time task to seed a new SQLite DB, or some sort of operation that will need to be repeated? Commented Mar 27, 2017 at 20:41
  • @Jason I'm looking to seed my data somehow Commented Mar 27, 2017 at 20:45
  • 1
    you can use SQLite Manager (a FF plugin) to create a db, and then include that in your project. You can try to modify your Insert query to work with SQLite, or just export the data from SQL and then import using SQLMgr Commented Mar 27, 2017 at 20:51
  • Why don't you just execute the command? Commented Mar 28, 2017 at 7:55

1 Answer 1

1

If you want to pre-seed your database and ship it with the app, then as Jason suggested, you can use SQLite Manager.

If you want the mobile app to seed the database on first load, you will need to create the objects (tables) first and run the below for each table you have.

SQLiteConnection conn = ....
conn.CreateTable<TableClass>();

Then if you just want to run the insert queries you have, you can use the Execute method.

public int Execute(string query, params object[] args)

However SQLite isn't as powerful as MS SQL and if your insert queries are complex, you will have to modify them and possibly your DB Schema, depending upon column types.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.