Skip to content

A library to allow multiple applications to share a single SQLite database

License

Notifications You must be signed in to change notification settings

FFMG/SQLiteServer

Repository files navigation

MyOddWeb.com SQLiteServer Release Build Status

A library to allow multiple applications/processes to share a single SQLite database

Nuget

Package manager

Install-Package MyOddWeb.Data.SQLiteServer -Version 0.1.2.1

CLI

.NET

dotnet add package MyOddWeb.Data.SQLiteServer --version 0.1.2.1

Packet

paket add MyOddWeb.Data.SQLiteServer --version 0.1.2.1

Why?

A common issue with SQLite is that, by design, only one process can connect to the database, while this is a perfectly normal use case, (and by design), there are some cases where more than one applications might want to share some data, (one does all the insert while another does the queries.)

Sample

Sample application

In the folder \console\ there is a sample application, start one or more instance of this app and you can run queries.

Application #1

var connection = new SQLiteServerConnection($"Data Source={source};Version=3;", Address, Port, Backlog, HeartBeatTimeOut);
connection.Open();
try
{
  using (var command = new SQLiteServerCommand(s, connection))
  {
    using (var reader = command.ExecuteReader())
    {
      while (reader.Read())
      {
        Console.WriteLine($"\t{reader[0]}");
      }
    }
  }
}
catch (SQLiteServerException e)
{
  Console.WriteLine( e.Message );
}
connection.Close();

Application #2

Basically do the same thing...

var connection = new SQLiteServerConnection($"Data Source={source};Version=3;", Address, Port, Backlog, HeartBeatTimeOut);
connection.Open();
try
{
  using (var command = new SQLiteServerCommand(s, connection))
  {
    using (var reader = command.ExecuteReader())
    {
      while (reader.Read())
      {
        Console.WriteLine($"\t{reader[0]}");
      }
    }
  }
}
catch (SQLiteServerException e)
{
  Console.WriteLine( e.Message );
}
connection.Close();

Performance

The initial tests showed that server was as fast as the default libraries, (but of course slower than the C++ library itself)

Data files are either similar speed or a tiny bit slower, (see the results below) :memory: datasource, is, of course, a lot slower.

0.1.1.1

Please see the performance app to run your own tests, \performance\SQLiteServerPerformance.sln.

Past results

Todo

Performance

While 'similar' performance will never be achieved, I am aiming for a degradation of no more than 5%.

I am using the \performance\SQLiteServerPerformance.sln application to run comparaison tests.

A couple of common SQLite commands are missing.

  • BackupDatabase 0.1.2.1
  • IsDBNull( idx ) 0.1.1.0
  • HasRows 0.1.1.0
  • FieldCount 0.1.1.0
  • GetName( idx ) 0.1.1.0
  • GetTableName( idx ) 0.1.1.0

A little less important, (but still need to be added)

  • GetBoolean( idx ) 0.1.1.2
  • GetGuid( idx ) 0.1.2.1
  • GetByte( idx ) 0.1.2.1
  • GetChar( idx ) 0.1.2.1
  • GetDateTime( idx )
  • GetDataTypeName( idx ) 0.1.1.3
  • GetDecimal( idx ) 0.1.1.2
  • GetDouble( idx ) 0.1.1.0
  • GetFloat( idx ) 0.1.1.2
  • NextResult() 0.1.1.3

Other

  • Namepipe might be faster, need to investigate more.
  • Create Nuget package
  • Some code cleanup
  • Performance testing/report. 0.1.1.0
  • SQLiteServerConnection should implement DbConnection 0.1.1.1
  • SQLiteServerCommand should implement DbCommand
    • Need to implement DbCommand CreateDbCommand(){} when this is done
  • SqliteServerDataReader should implement DbDataReader
  • SQLiteServerTransaction should implement DbTransaction 0.1.1.1

Acknowledgement

If I forgot someone, please let me know and I will gladly add them here :)

About

A library to allow multiple applications to share a single SQLite database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published