[DBTools] Add new param, update usage

This commit is contained in:
Matt Nadareski
2016-09-01 23:17:09 -07:00
parent 6444f83aee
commit 14a701b05a
5 changed files with 24 additions and 54 deletions

View File

@@ -12,19 +12,20 @@ namespace SabreTools.Helper
/// <summary>
/// Ensure that the databse exists and has the proper schema
/// </summary>
/// <param name="type">Schema type to use</param>
/// <param name="db">Name of the databse</param>
/// <param name="connectionString">Connection string for SQLite</param>
public static void EnsureDatabase(string db, string connectionString)
public static void EnsureDatabase(string type, string db, string connectionString)
{
// Set the type to lowercase
type = type.ToLowerInvariant();
// Make sure the file exists
if (!File.Exists(db))
{
SqliteConnection.CreateFile(db);
}
//Get "type" from the filename
string type = Path.GetFileNameWithoutExtension(db);
// Connect to the file
SqliteConnection dbc = new SqliteConnection(connectionString);
dbc.Open();
@@ -32,7 +33,18 @@ namespace SabreTools.Helper
// Make sure the database has the correct schema
try
{
if (type == "Headerer")
if (type == "rombasharp")
{
string query = @"
CREATE TABLE IF NOT EXISTS data (
'id' INTEGER NOT NULL
'key' TEXT NOT NULL
'value' TEXT NOT NULL
)";
SqliteCommand slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();
}
else if (type == "headerer")
{
string query = @"
CREATE TABLE IF NOT EXISTS data (