Need helping on database?

You must Login before you can answer or comment on any questions.

Hi, I have one database with two tables, for executing those two tables, can I create two separate variables or one variable is enough? can I follow like this, var db = Titanium.Database.install('mydata.sqlite','maintable','mycheck');

or

var db1 = Titanium.Database.install('mydata.sqlite','maintable');
var db2 = Titanium.Database.install('mydata.sqlite','mycheck');

— asked 2 years ago by lokesh g
0 Comments

2 Answers

Why do you want to create 2 databases? the database.install method is just a way of making a copy of your sqlite database to your device. So the first parameter is your SQLITE file and the second variable is how the db is called on your device (This has no use for you)

//mydata.sqlite = sqlite file
//db = how it will be called on your device when it makes a copy
var db1 = Titanium.Database.install('mydata.sqlite','db');
So if you would do
var db1 = Titanium.Database.install('mydata.sqlite','maintable');
var db2 = Titanium.Database.install('mydata.sqlite','mycheck');
You'd be installing the same database twice.

— answered 2 years ago by Tjeu Vdw
answer permalink
2 Comments
  • If I use like this, I want to insert values in different tables, then how it know without mentioned the table name, on which table it insert those values.

    — commented 2 years ago by lokesh g

  • The table is inside the database.

    A database contains tables, tables contain rows.

    So when you opened your database you can insert into your tables from that database

    So you'll be executing commands on your database like

    INSERT INTO tableName (ID, Name) VALUES (1, "Lokesh g")

    — commented 2 years ago by Tjeu Vdw

You don't understand, read documentation.

"Install" method installs database, second parameter is database name, while first is sqlite file to populate database with tables and data.

So, install database and then use SQL to get data from database tables.

Your Answer

Think you can help? Login to answer this question!