mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DBTools] Add new param, update usage
This commit is contained in:
@@ -33,6 +33,7 @@ namespace SabreTools
|
||||
|
||||
// Other private variables
|
||||
private string _config = "config.xml";
|
||||
private string _dbSchema = "rombasharp";
|
||||
private string _connectionString;
|
||||
private Logger _logger;
|
||||
|
||||
@@ -45,7 +46,7 @@ namespace SabreTools
|
||||
_logger = logger;
|
||||
|
||||
InitializeConfiguration();
|
||||
InitializeDatabase();
|
||||
DBTools.EnsureDatabase(_dbSchema, _db, _connectionString);
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
@@ -280,51 +281,6 @@ namespace SabreTools
|
||||
_port = port;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the Romba database
|
||||
/// </summary>
|
||||
private void InitializeDatabase()
|
||||
{
|
||||
// Make sure the db is set
|
||||
if (String.IsNullOrEmpty(_db))
|
||||
{
|
||||
_db = "db.sqlite";
|
||||
_connectionString = "Data Source=" + _db + ";Version = 3;";
|
||||
}
|
||||
|
||||
// Make sure the file exists
|
||||
if (!File.Exists(_db))
|
||||
{
|
||||
SqliteConnection.CreateFile(_db);
|
||||
}
|
||||
|
||||
// Connect to the file
|
||||
SqliteConnection dbc = new SqliteConnection(_connectionString);
|
||||
dbc.Open();
|
||||
|
||||
// Initialize the database schema
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Close the database connection
|
||||
dbc.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populate or refresh the database information
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user