public static void Main(string[] args) { new TAppSettingsManager(false); if (!TAppSettingsManager.HasValue("file")) { Console.WriteLine("call: echo SELECT * FROM s_user | SQLiteConsole -file:mydatabase.db -password:secret"); Environment.Exit(1); } try { if (!System.IO.File.Exists(TAppSettingsManager.GetValue("file"))) { Console.WriteLine("database file " + TAppSettingsManager.GetValue("file") + " does not exist"); // this is to avoid InitDBConnection trying to find/copy the base database Environment.Exit(1); } if (!InitDBConnection(TAppSettingsManager.GetValue("file"), TAppSettingsManager.GetValue("password", ""))) { Console.WriteLine("cannot connect to database " + TAppSettingsManager.GetValue("file")); Environment.Exit(1); } string SQLCommand = ""; string line; while ((line = Console.ReadLine()) != null && line.Length > 0) { SQLCommand += " " + line.Trim(); } TDBTransaction transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted); DataTable result = DBAccess.GDBAccessObj.SelectDT(SQLCommand, "temp", transaction); TDataBase.LogTable(result); DBAccess.GDBAccessObj.RollbackTransaction(); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } if (db.ConnectionOK) { db.CloseDBConnection(); } }
public static void Main(string[] args) { new TAppSettingsManager(false); if (!TAppSettingsManager.HasValue("file")) { Console.WriteLine("call: echo SELECT * FROM s_user | SQLiteConsole -file:mydatabase.db -password:secret"); Environment.Exit(1); } try { if (!System.IO.File.Exists(TAppSettingsManager.GetValue("file"))) { Console.WriteLine("database file " + TAppSettingsManager.GetValue("file") + " does not exist"); // this is to avoid InitDBConnection trying to find/copy the base database Environment.Exit(1); } if (!InitDBConnection(TAppSettingsManager.GetValue("file"), TAppSettingsManager.GetValue("password", ""))) { Console.WriteLine("cannot connect to database " + TAppSettingsManager.GetValue("file")); Environment.Exit(1); } string SQLCommand = ""; string line; while ((line = Console.ReadLine()) != null && line.Length > 0) { SQLCommand += " " + line.Trim(); } TDBTransaction transaction = new TDBTransaction(); DataTable result = null; db.ReadTransaction(ref transaction, delegate { result = db.SelectDT(SQLCommand, "temp", transaction); }); if (result == null) { TLogging.Log("The query returned a NULL table of results!"); } else { TDataBase.LogTable(result); } } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } if (db.ConnectionOK) { db.CloseDBConnection(); } }