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.
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 onSQLConnection
it looks exactly what you need.I haven't tested this, but according to the documentation it should work:
There may be errors in that code snipplet, I haven't worked much with the AIR SQL API lately. Notice that the tables of the database opened with
open
are available usingmain.tableName
, any attached database can be given any name at all (otherDb
in the example above).It's possible to open multiple databases at once in Sqlite, but it's doubtful if can be done when working from Flex/AIR. In the command line client you run
ATTACH DATABASE path/to/other.db AS otherDb
and then you can refer to tables in that database asotherDb.tableName
just as in MySQL or SQL Server.this code can be work,it is write of me: