Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#230 Implement new MariaDB connector #243

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions HeadlessExport/App.config
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
Expand All @@ -17,6 +17,14 @@
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.29.0" newVersion="8.0.29.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
</configuration>
3 changes: 2 additions & 1 deletion HeadlessExport/HeadlessExport.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<OutputType>Exe</OutputType>
<RootNamespace>HeadlessExport</RootNamespace>
<AssemblyName>HeadlessExport</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
26 changes: 16 additions & 10 deletions SpellGUIV2/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
Expand All @@ -30,7 +22,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
Expand All @@ -40,6 +32,20 @@
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.29.0" newVersion="8.0.29.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data>
</configuration>
Binary file modified SpellGUIV2/Costura32/SQLite.Interop.dll
Binary file not shown.
Binary file modified SpellGUIV2/Costura64/SQLite.Interop.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion SpellGUIV2/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ private async Task GetConfig()
Config.Database = db;
}
}
Config.connectionType = isSqlite ? Config.ConnectionType.SQLite : Config.ConnectionType.MySQL;
Config.connectionType = isSqlite ? Config.ConnectionType.SQLite : /*Config.ConnectionType.MySQL*/Config.ConnectionType.MariaDB;
Config.IsInit = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions SpellGUIV2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.4.0")]
[assembly: AssemblyFileVersion("2.2.4.0")]
[assembly: AssemblyVersion("2.2.4.1")]
[assembly: AssemblyFileVersion("2.2.4.1")]
2 changes: 1 addition & 1 deletion SpellGUIV2/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SpellGUIV2/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion SpellGUIV2/Sources/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public static class Config
public enum ConnectionType
{
SQLite,
MySQL
MySQL,
MariaDB
}

public static bool IsInit = false;
Expand Down
101 changes: 101 additions & 0 deletions SpellGUIV2/Sources/Database/AbstractAdapter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using SpellEditor.Sources.Binding;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace SpellEditor.Sources.Database
{
public abstract class AbstractAdapter : IDatabaseAdapter, IDisposable
{
protected readonly object _syncLock = new object();
public bool Updating { get; set; }

public List<string> GetAllTableCreateStrings()
{
var list = new List<string>();
foreach (var binding in BindingManager.GetInstance().GetAllBindings())
{
list.Add(string.Format(GetTableCreateString(binding), binding.Name.ToLower()));
}
return list;
}

public virtual string GetTableCreateString(Binding.Binding binding)
{
StringBuilder str = new StringBuilder();
str.Append(@"CREATE TABLE IF NOT EXISTS `{0}` (");
foreach (var field in binding.Fields)
{
switch (field.Type)
{
case BindingType.UINT:
str.Append($@"`{field.Name}` int(10) unsigned NOT NULL DEFAULT '0', ");
break;
case BindingType.INT:
str.Append($@"`{field.Name}` int(11) NOT NULL DEFAULT '0', ");
break;
case BindingType.UINT8:
str.Append($@"`{field.Name}` tinyint unsigned NOT NULL DEFAULT '0', ");
break;
case BindingType.FLOAT:
str.Append($@"`{field.Name}` FLOAT NOT NULL DEFAULT '0', ");
break;
case BindingType.STRING_OFFSET:
str.Append($@"`{field.Name}` TEXT CHARACTER SET utf8, ");
break;
default:
throw new Exception($"ERROR: Unhandled type: {field.Type} on field: {field.Name} on binding: {binding.Name}");
}
}

var idField = binding.Fields.FirstOrDefault(record => record.Name.ToLower().Equals("id"));
if (idField != null && binding.OrderOutput)
str.Append($"PRIMARY KEY (`{idField.Name}`)) ");
else
{
str = str.Remove(str.Length - 2, 2);
str = str.Append(") ");
}
str.Append("ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;");
return str.ToString();
}

public virtual void CreateAllTablesFromBindings()
{
throw new NotImplementedException();
}

public virtual void Dispose()
{
throw new NotImplementedException();
}


public virtual void CommitChanges(string query, DataTable dataTable)
{
throw new NotImplementedException();
}

public virtual string EscapeString(string str)
{
throw new NotImplementedException();
}

public virtual void Execute(string p)
{
throw new NotImplementedException();
}

public virtual DataTable Query(string query)
{
throw new NotImplementedException();
}

public virtual object QuerySingleValue(string query)
{
throw new NotImplementedException();
}
}
}
4 changes: 3 additions & 1 deletion SpellGUIV2/Sources/Database/AdapterFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public IDatabaseAdapter GetAdapter(bool initialiseDatabase)
return new MySQL(initialiseDatabase);
case Config.Config.ConnectionType.SQLite:
return new SQLite();
case Config.Config.ConnectionType.MariaDB:
return new MariaDB(initialiseDatabase);
default:
throw new Exception("Unknown config connection type, valid types: MySQL, SQLite");
throw new Exception("Unknown config connection type, valid types: MySQL, MariaDB, SQLite");
}
}

Expand Down
Loading