Using multiple SQLite databases at once

Question :

Using multiple SQLite databases at once,

Answer :

I have 2 SQLite databases, one downloaded from a server (server.db), and one used as storage on the client (client.db). I need to perform various sync queries on the client database, using data from the server database.

For example, I want to delete all rows in the client.db tRole table, and repopulate with all rows in the server.db tRole table.

Another example, I want to delete all rows in the client.db tFile table where the fileID is not in the server.db tFile table.

Read More  Where to put your code – Database vs. Application?

In SQL Server you can just prefix the table with the name of the database. Is there anyway to do this in SQLite using Adobe Air?

,

I just looked at the AIR SQL API, and there’s an attach method on SQLConnection it looks exactly what you need.

I haven’t tested this, but according to the documentation it should work:

var connection : SQLConnection = new SQLConnection();    connection.open(firstDbFile);  connection.attach(secondDbFile, "otherDb");    var statement : SQLStatement = new SQLStatement();    statement.connection = connection;  statement.text = "INSERT INTO main.myTable SELECT * FROM otherDb.myTable";  statement.execute();  

There may be errors in that code snippet, I haven’t worked much with the AIR SQL API lately. Notice that the tables of the database opened with open are available using main.tableName, any attached database can be given any name at all (otherDb in the example above).

Read More  Difference between NULL and null in PHP

That’s the answer Using multiple SQLite databases at once, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you