SQLite Forum

Mono.Data.Sqlite In-Memory Shared Database
I'm away from my Mono-running machine for a few days, so did not try that. I doubt it matters because the same implemented-in-C code is reached regardless of whether Mono or some other .Net platform adapter layer is used, or just the C API is directly called. While it may be true that some implementation differences exist in .Net on its various platforms, I highly doubt that this is affecting anything so fundamental as passing parameters from your code, through the adapter layer, to the actual SQLite3 C API that handles the DB open.

I tried using the sqlite3.exe shell, but since that is distributed without SQLITE\_USE\_URI defined, I used a locally built one where it is defined. That, of course, makes it harder to see the effect of independent "connections" to the same, shared-memory DB.

So, to show that a shared memory DB works as documented, I wrote and ran this little Perl program, named shmem.pl:

use DBI;
use DBD::SQLite;
use autodie;

my $dbh1 = DBI->connect("dbi:SQLite:uri=file:somemem?mode=memory&cache=shared", '', '',
                       { AutoCommit => 1, RaiseError => 1 });

my $dbh2 = DBI->connect("dbi:SQLite:uri=file:somemem?mode=memory&cache=shared", '', '',
                       { AutoCommit => 1, RaiseError => 1 });

$dbh1->do("create table Furd(name text)");

$dbh1->do("insert into Furd values ('Bird')");
$dbh1->do("insert into Furd values ('Burp')");

my $sth = $dbh2->prepare("select * from Furd");

my $rv = $sth->execute() or die $DBI::errstr;

if($rv < 0) {
   print $DBI::errstr;

while(my $row = $sth->fetch) {
      print $row->[0] . "\n";


which produced the following output:

> perl shmem.pl


As you can see, the table with values created via $dbh1 was read via $dbh2.

I encourage you to investigate your calls rather than .Net platform differences.

Good luck!

(Edited to add:)
None of this contravene's Keith's advice. If the SQLite library you are using was not compiled with SQLITE\_USE\_URI defined, you will need to study and carefully heed [Uniform Resource Identifiers](https://www.sqlite.org/uri.html) section 2.