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:
parent
2150061c91
commit
bb96825c60
Assets/dll
References/x64/SQLite
src/BizHawk.Client.Common
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,23 +1,26 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Microsoft.Data.Sqlite;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public sealed class SQLiteApi : ISQLiteApi
|
||||
{
|
||||
private SQLiteConnection _dbConnection;
|
||||
private SqliteConnection _dbConnection;
|
||||
|
||||
public string CreateDatabase(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
SQLiteConnection.CreateFile(name);
|
||||
File.Create(name).Dispose();
|
||||
}
|
||||
catch (SQLiteException sqlEx)
|
||||
catch (Exception ex)
|
||||
{
|
||||
return sqlEx.Message;
|
||||
return ex.Message;
|
||||
}
|
||||
|
||||
return "Database Created Successfully";
|
||||
}
|
||||
|
||||
|
@ -25,18 +28,18 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
try
|
||||
{
|
||||
_dbConnection = new SQLiteConnection(
|
||||
new SQLiteConnectionStringBuilder {
|
||||
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?.Dispose();
|
||||
_dbConnection = new(new SqliteConnectionStringBuilder { DataSource = name }.ToString());
|
||||
_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;
|
||||
}
|
||||
|
@ -52,10 +55,11 @@ namespace BizHawk.Client.Common
|
|||
try
|
||||
{
|
||||
_dbConnection.Open();
|
||||
new SQLiteCommand(query, _dbConnection).ExecuteNonQuery();
|
||||
using var cmd = new SqliteCommand(query, _dbConnection);
|
||||
cmd.ExecuteNonQuery();
|
||||
result = "Command ran successfully";
|
||||
}
|
||||
catch (SQLiteException sqlEx)
|
||||
catch (SqliteException sqlEx)
|
||||
{
|
||||
result = sqlEx.Message;
|
||||
}
|
||||
|
@ -71,7 +75,7 @@ namespace BizHawk.Client.Common
|
|||
try
|
||||
{
|
||||
_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();
|
||||
if (reader.HasRows)
|
||||
{
|
||||
|
@ -92,7 +96,7 @@ namespace BizHawk.Client.Common
|
|||
result = "No rows found";
|
||||
}
|
||||
}
|
||||
catch (SQLiteException sqlEx)
|
||||
catch (SqliteException sqlEx)
|
||||
{
|
||||
result = sqlEx.Message;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
<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" />
|
||||
<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 -->
|
||||
<ProjectReference Include="$(ProjectDir)../BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj" />
|
||||
<ProjectReference Include="$(ProjectDir)../BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj" />
|
||||
|
|
Loading…
Reference in New Issue