mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DBTools] Remove old database stuff
This commit is contained in:
Binary file not shown.
@@ -32,69 +32,7 @@ namespace SabreTools.Helper
|
|||||||
// Make sure the database has the correct schema
|
// Make sure the database has the correct schema
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (type == "DATabase")
|
if (type == "Headerer")
|
||||||
{
|
|
||||||
string query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS checksums (
|
|
||||||
'file' INTEGER NOT NULL,
|
|
||||||
'size' INTEGER NOT NULL DEFAULT -1,
|
|
||||||
'crc' TEXT NOT NULL,
|
|
||||||
'md5' TEXT NOT NULL,
|
|
||||||
'sha1' TEXT NOT NULL,
|
|
||||||
PRIMARY KEY (file, size, crc, md5, sha1)
|
|
||||||
)";
|
|
||||||
SqliteCommand slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS files (
|
|
||||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
|
||||||
'setid' INTEGER NOT NULL,
|
|
||||||
'name' TEXT NOT NULL,
|
|
||||||
'type' TEXT NOT NULL DEFAULT 'rom',
|
|
||||||
'lastupdated' TEXT NOT NULL
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS games (
|
|
||||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
|
||||||
'system' INTEGER NOT NULL,
|
|
||||||
'name' TEXT NOT NULL,
|
|
||||||
'parent' INTEGER NOT NULL DEFAULT '0',
|
|
||||||
'source' INTEGER NOT NULL DEFAULT '0'
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS parent (
|
|
||||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
|
||||||
'name' TEXT NOT NULL
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS sources (
|
|
||||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
|
||||||
'name' TEXT NOT NULL UNIQUE,
|
|
||||||
'url' TEXT NOT NULL
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS systems (
|
|
||||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
|
||||||
'manufacturer' TEXT NOT NULL,
|
|
||||||
'system' TEXT NOT NULL
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
else if (type == "Headerer")
|
|
||||||
{
|
{
|
||||||
string query = @"
|
string query = @"
|
||||||
CREATE TABLE IF NOT EXISTS data (
|
CREATE TABLE IF NOT EXISTS data (
|
||||||
@@ -106,65 +44,6 @@ CREATE TABLE IF NOT EXISTS data (
|
|||||||
SqliteCommand slc = new SqliteCommand(query, dbc);
|
SqliteCommand slc = new SqliteCommand(query, dbc);
|
||||||
slc.ExecuteNonQuery();
|
slc.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
else if (type == "SabreTools")
|
|
||||||
{
|
|
||||||
string query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS hash (
|
|
||||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
|
||||||
'size' INTEGER NOT NULL DEFAULT -1,
|
|
||||||
'crc' TEXT NOT NULL,
|
|
||||||
'md5' TEXT NOT NULL,
|
|
||||||
'sha1' TEXT NOT NULL
|
|
||||||
)";
|
|
||||||
SqliteCommand slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS hashdata (
|
|
||||||
'hashid' INTEGER NOT NULL,
|
|
||||||
'key' TEXT NOT NULL,
|
|
||||||
'value' TEXT,
|
|
||||||
PRIMARY KEY (hashid, key, value)
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS source (
|
|
||||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
|
||||||
'name' TEXT NOT NULL UNIQUE,
|
|
||||||
'url' TEXT NOT NULL
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS system (
|
|
||||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
|
||||||
'manufacturer' TEXT NOT NULL,
|
|
||||||
'name' TEXT NOT NULL
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS gamesystem (
|
|
||||||
'game' TEXT NOT NULL,
|
|
||||||
'systemid' INTEGER NOT NULL,
|
|
||||||
PRIMARY KEY (game, systemid)
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
|
|
||||||
query = @"
|
|
||||||
CREATE TABLE IF NOT EXISTS gamesource (
|
|
||||||
'game' TEXT NOT NULL,
|
|
||||||
'sourceid' INTEGER NOT NULL,
|
|
||||||
PRIMARY KEY (game, sourceid)
|
|
||||||
)";
|
|
||||||
slc = new SqliteCommand(query, dbc);
|
|
||||||
slc.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
else if (type == "dats")
|
else if (type == "dats")
|
||||||
{
|
{
|
||||||
string query = @"
|
string query = @"
|
||||||
@@ -226,7 +105,7 @@ CREATE TABLE IF NOT EXISTS system (
|
|||||||
/// <returns>True if the source existed or could be added, false otherwise</returns>
|
/// <returns>True if the source existed or could be added, false otherwise</returns>
|
||||||
public static bool AddSource(string name, string url, string connectionString)
|
public static bool AddSource(string name, string url, string connectionString)
|
||||||
{
|
{
|
||||||
string query = "SELECT id, name, url FROM sources WHERE name='" + name + "'";
|
string query = "SELECT id, name, url FROM source WHERE name='" + name + "'";
|
||||||
using (SqliteConnection dbc = new SqliteConnection(connectionString))
|
using (SqliteConnection dbc = new SqliteConnection(connectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
@@ -237,7 +116,7 @@ CREATE TABLE IF NOT EXISTS system (
|
|||||||
// If nothing is found, add the source
|
// If nothing is found, add the source
|
||||||
if (!sldr.HasRows)
|
if (!sldr.HasRows)
|
||||||
{
|
{
|
||||||
string squery = "INSERT INTO sources (name, url) VALUES ('" + name + "', '" + url + "')";
|
string squery = "INSERT INTO source (name, url) VALUES ('" + name + "', '" + url + "')";
|
||||||
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
||||||
{
|
{
|
||||||
return sslc.ExecuteNonQuery() >= 1;
|
return sslc.ExecuteNonQuery() >= 1;
|
||||||
@@ -249,7 +128,7 @@ CREATE TABLE IF NOT EXISTS system (
|
|||||||
sldr.Read();
|
sldr.Read();
|
||||||
if (url != sldr.GetString(2))
|
if (url != sldr.GetString(2))
|
||||||
{
|
{
|
||||||
string squery = "UPDATE sources SET url='" + url + "' WHERE id=" + sldr.GetInt32(0);
|
string squery = "UPDATE source SET url='" + url + "' WHERE id=" + sldr.GetInt32(0);
|
||||||
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
||||||
{
|
{
|
||||||
return sslc.ExecuteNonQuery() >= 1;
|
return sslc.ExecuteNonQuery() >= 1;
|
||||||
@@ -271,7 +150,7 @@ CREATE TABLE IF NOT EXISTS system (
|
|||||||
/// <returns>True if the source was removed, false otherwise</returns>
|
/// <returns>True if the source was removed, false otherwise</returns>
|
||||||
public static bool RemoveSource(int id, string connectionString)
|
public static bool RemoveSource(int id, string connectionString)
|
||||||
{
|
{
|
||||||
string query = "DELETE FROM sources WHERE id=" + id;
|
string query = "DELETE FROM source WHERE id=" + id;
|
||||||
using (SqliteConnection dbc = new SqliteConnection(connectionString))
|
using (SqliteConnection dbc = new SqliteConnection(connectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
@@ -291,7 +170,7 @@ CREATE TABLE IF NOT EXISTS system (
|
|||||||
/// <returns>True if the system existed or could be added, false otherwise</returns>
|
/// <returns>True if the system existed or could be added, false otherwise</returns>
|
||||||
public static bool AddSystem(string manufacturer, string system, string connectionString)
|
public static bool AddSystem(string manufacturer, string system, string connectionString)
|
||||||
{
|
{
|
||||||
string query = "SELECT id, manufacturer, system FROM systems WHERE manufacturer='" + manufacturer + "' AND system='" + system + "'";
|
string query = "SELECT id, manufacturer, name FROM system WHERE manufacturer='" + manufacturer + "' AND system='" + system + "'";
|
||||||
using (SqliteConnection dbc = new SqliteConnection(connectionString))
|
using (SqliteConnection dbc = new SqliteConnection(connectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
@@ -302,7 +181,7 @@ CREATE TABLE IF NOT EXISTS system (
|
|||||||
// If nothing is found, add the system
|
// If nothing is found, add the system
|
||||||
if (!sldr.HasRows)
|
if (!sldr.HasRows)
|
||||||
{
|
{
|
||||||
string squery = "INSERT INTO systems (manufacturer, system) VALUES ('" + manufacturer + "', '" + system + "')";
|
string squery = "INSERT INTO name (manufacturer, system) VALUES ('" + manufacturer + "', '" + system + "')";
|
||||||
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
||||||
{
|
{
|
||||||
return sslc.ExecuteNonQuery() >= 1;
|
return sslc.ExecuteNonQuery() >= 1;
|
||||||
@@ -322,7 +201,7 @@ CREATE TABLE IF NOT EXISTS system (
|
|||||||
/// <returns>True if the system was removed, false otherwise</returns>
|
/// <returns>True if the system was removed, false otherwise</returns>
|
||||||
public static bool RemoveSystem(int id, string connectionString)
|
public static bool RemoveSystem(int id, string connectionString)
|
||||||
{
|
{
|
||||||
string query = "DELETE FROM systems WHERE id=" + id;
|
string query = "DELETE FROM system WHERE id=" + id;
|
||||||
using (SqliteConnection dbc = new SqliteConnection(connectionString))
|
using (SqliteConnection dbc = new SqliteConnection(connectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
|
|||||||
@@ -106,9 +106,6 @@
|
|||||||
<Compile Include="Data\Build.cs" />
|
<Compile Include="Data\Build.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="DATabase.sqlite">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Include="dats.sqlite">
|
<None Include="dats.sqlite">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
@@ -116,9 +113,6 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="SabreTools.sqlite">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Mappings\*.xml">
|
<Content Include="Mappings\*.xml">
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user