Multiple Sqlite databases

20 views
Skip to first unread message

Tyler Chesley

unread,
Jul 3, 2009, 4:52:32 PM7/3/09
to restfulx-framework
Does anyone have an elegant way of having more than one Sqlite
database in an Air app? I've looked at the AirServiceProvider source
and it is setup to only use the Rx.airDatabaseName to find a database
effectively limiting you to one Sqlite database as far as I can tell.

Dima Berastau

unread,
Jul 3, 2009, 5:45:09 PM7/3/09
to restfulx-...@googlegroups.com
Hi Tyler,

Rx.airDatabaseName is the default. You can create multiple instances
of AIRServiceProvider and initialize each one of them with a different
DB file.

For example.

var service1:AIRServiceProvider = new AIRServiceProvider(fileA);
var service2:AIRServiceProvider = new AIRServiceProvider(fileB);

then register them:

Rx.services.addServiceProvider(service1);
Rx.services.addServiceProvider(service2);

And you should be able to switch between different service providers
on a per method basis or set the appropriate one as default depending
on your requirements.

Hope that helps,
Dima

Tyler Chesley

unread,
Jul 3, 2009, 10:58:04 PM7/3/09
to restfulx-...@googlegroups.com
Thanks, Dima. That worked like a charm.

Chuck Horton

unread,
Mar 9, 2011, 11:46:15 PM3/9/11
to restfulx-...@googlegroups.com
I trying to get two Sqlite databases and one RAILS database working together. Below is the code I have tried. This gets one sqlite database working and one RAiLS database working but not the second Sqlite database working.

When creating two AIRServiceProviders it uses the same id of 2 for both. Is this possible, if so what am I missing?

ApplicationController.initialize([AIRServiceProvider], XMLHTTPServiceProvider.ID, "actionplanr"); 
Rx.defaultServiceId = XMLHTTPServiceProvider.ID;

//Actonplanr Main Database (since with RAILS)
var actionplanrFile:File = File.userDirectory.resolvePath("actionplanr.db");
AIRactionplanrService = new AIRServiceProvider(actionplanrFile); 

//Actonplanr System Database (templates and others, no sync)
var actionplanrSysFile:File = File.userDirectory.resolvePath("actionplanrsys.db");
AIRactionplanrSysService = new AIRServiceProvider(actionplanrSysFile); 

Rx.services.addServiceProvider(AIRactionplanrService);
Rx.services.addServiceProvider(AIRactionplanrSysService);

trace("AIRactionplanrService.ID: " + AIRactionplanrService.id);  //= 2
trace("AIRactionplanrSysService.ID: " + AIRactionplanrSysService.id); //= 2

Thanks, Chuck

Chuck Horton

unread,
May 9, 2011, 12:00:43 PM5/9/11
to restfulx-...@googlegroups.com
Anybody have an idea on this problem?
Reply all
Reply to author
Forward
0 new messages