You can open a :memory: database for the main database, then ATTACH your other database files. This works just fine without shared cache and does achieve your objective of always permitting access using qualified names. Be aware though that using unqualified names for a select will use the name found in the firstly attached database in which it exists (though I do not know if the search order is guaranteed).
Unqualified creates will create the object in the memory database. Except for associated items, of course, which are created in the attached database in which they were found (I believe -- I've always created the database schema using a direct connection and only used the multiple attached database files for DML, not to create new objects). I've done this many times by writing an "opener" for existing databases all located in a single directory that opens :memory: first, then attaches every database found in the directory. Haven't tried with a shared-cache through. If you want to use a single shared memory cache, you should be able to open a shared-memory database as the "main" database then attach the database files in shared-cache mode by using URI format names: Open "file::memory:?cache=shared" for the "main" database, then attach each of the other databases using ATTACH 'file:filename?cache=shared' as dbname; You have to have compiled the engine with URI names support for this to work (is this the default?) Note that you *must* open the main database using the URI format name to get a shared memory database. Personally, I would use URI name formats for explicitly set shared-cache. --- () ascii ribbon campaign against html e-mail /\ www.asciiribbon.org > -----Original Message----- > From: [email protected] [mailto:sqlite-users- > [email protected]] On Behalf Of Grace Simon Batumbya > Sent: Monday, 16 July, 2012 11:35 > To: General Discussion of SQLite Database > Cc: Carlin Desautels > Subject: Re: [sqlite] Enabling shared-cache, breaking attach database > > On 7/16/2012 12:44, Richard Hipp wrote: > > On Mon, Jul 16, 2012 at 12:37 PM, Grace Batumbya < > > [email protected]> wrote: > > > >> Hi there, > >> With the shared-cache enabled, attaching a database to a second instance > >> of the database connection throws an error : "database is already > attached". > >> Why does this happen? is it by design or is it a bug? > >> > > We would not have had an error message for this specific issue where it not > > by design. But that design happened so long ago, that I do not recall the > > reason, right off hand, why the restriction is in place. > > > > Why do you want to attach the same database twice? What are you hoping to > > accomplish? > > We are using SQLite in a concurrent environment. The second connection > would be on a new thread. We like to refer to DB objects using > fully-qualified names; hence the need to attach databases for each > connection. > > *Grace Batumbya* > Research Assistant | Seneca CDOT > Phone: 416-491-5050 x3548 > cdot.senecac.on.ca <http://cdot.senecac.on.ca/> > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

