System.Data.SQLite -> Microsoft.Data.Sqlite (#3719)

* Swap System.Data.SQLite with Microsoft.Data.Sqlite

Apparently this is supposed to be a kind of successor? https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/compare

* Add e_sqlite3 libs to Assets, prevent runtimes folder creation with OS tailored libs plopped in, delete System.Data.SQLite references
This commit is contained in:
CasualPokePlayer 2023-08-05 17:45:40 -07:00 committed by GitHub
parent 2150061c91
commit bb96825c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 17195 deletions

BIN
Assets/dll/e_sqlite3.dll Normal file

Binary file not shown.

BIN
Assets/dll/libe_sqlite3.so Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,26 @@
using System.Collections.Generic; using System;
using System.Data; using System.Collections.Generic;
using System.Data.SQLite; using System.IO;
using Microsoft.Data.Sqlite;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
public sealed class SQLiteApi : ISQLiteApi public sealed class SQLiteApi : ISQLiteApi
{ {
private SQLiteConnection _dbConnection; private SqliteConnection _dbConnection;
public string CreateDatabase(string name) public string CreateDatabase(string name)
{ {
try try
{ {
SQLiteConnection.CreateFile(name); File.Create(name).Dispose();
} }
catch (SQLiteException sqlEx) catch (Exception ex)
{ {
return sqlEx.Message; return ex.Message;
} }
return "Database Created Successfully"; return "Database Created Successfully";
} }
@ -25,18 +28,18 @@ namespace BizHawk.Client.Common
{ {
try try
{ {
_dbConnection = new SQLiteConnection( _dbConnection?.Dispose();
new SQLiteConnectionStringBuilder { _dbConnection = new(new SqliteConnectionStringBuilder { DataSource = name }.ToString());
DataSource = name,
Version = 3,
JournalMode = SQLiteJournalModeEnum.Wal, // Allows for reads and writes to happen at the same time
DefaultIsolationLevel = IsolationLevel.ReadCommitted, // This only helps make the database lock left. May be pointless now
SyncMode = SynchronizationModes.Off // This shortens the delay for do synchronous calls.
}.ToString()
);
_dbConnection.Open(); _dbConnection.Open();
using var initCmds = new SqliteCommand(null, _dbConnection);
// Allows for reads and writes to happen at the same time
initCmds.CommandText = "PRAGMA journal_mode = 'wal'";
initCmds.ExecuteNonQuery();
// This shortens the delay for do synchronous calls
initCmds.CommandText = "PRAGMA synchronous = 'off'";
initCmds.ExecuteNonQuery();
} }
catch (SQLiteException sqlEx) catch (SqliteException sqlEx)
{ {
return sqlEx.Message; return sqlEx.Message;
} }
@ -52,10 +55,11 @@ namespace BizHawk.Client.Common
try try
{ {
_dbConnection.Open(); _dbConnection.Open();
new SQLiteCommand(query, _dbConnection).ExecuteNonQuery(); using var cmd = new SqliteCommand(query, _dbConnection);
cmd.ExecuteNonQuery();
result = "Command ran successfully"; result = "Command ran successfully";
} }
catch (SQLiteException sqlEx) catch (SqliteException sqlEx)
{ {
result = sqlEx.Message; result = sqlEx.Message;
} }
@ -71,7 +75,7 @@ namespace BizHawk.Client.Common
try try
{ {
_dbConnection.Open(); _dbConnection.Open();
using var command = new SQLiteCommand($"PRAGMA read_uncommitted =1;{query}", _dbConnection); using var command = new SqliteCommand($"PRAGMA read_uncommitted =1;{query}", _dbConnection);
using var reader = command.ExecuteReader(); using var reader = command.ExecuteReader();
if (reader.HasRows) if (reader.HasRows)
{ {
@ -92,7 +96,7 @@ namespace BizHawk.Client.Common
result = "No rows found"; result = "No rows found";
} }
} }
catch (SQLiteException sqlEx) catch (SqliteException sqlEx)
{ {
result = sqlEx.Message; result = sqlEx.Message;
} }

View File

@ -8,8 +8,8 @@
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System.Data.SQLite, Version=1.0.105.2, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64" SpecificVersion="False" HintPath="$(ProjectDir)../../References/x64/SQLite/System.Data.SQLite.dll" Private="true" />
<Reference Include="NLua, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL" SpecificVersion="false" HintPath="$(ProjectDir)../../References/NLua.dll" Private="true" /> <Reference Include="NLua, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL" SpecificVersion="false" HintPath="$(ProjectDir)../../References/NLua.dll" Private="true" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.9" ExcludeAssets="buildTransitive" />
<PackageReference Include="SharpCompress" Version="0.31.0" /><!-- can't update any further or .gz stops being detected as archive --> <PackageReference Include="SharpCompress" Version="0.31.0" /><!-- can't update any further or .gz stops being detected as archive -->
<ProjectReference Include="$(ProjectDir)../BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj" /> <ProjectReference Include="$(ProjectDir)../BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj" /> <ProjectReference Include="$(ProjectDir)../BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj" />