public override string[] GetDatabaseStructure(SwapQLConnection tConnection) { var createStatements = new List <string>(); var tables = Connection.GetSchema("Tables", new[] { null, AccessConfig.Source.Databasename }); foreach (DataRow table in tables.Rows) { var tableName = table[2] as string; var dt = Connection.GetSchema("Columns", new[] { null, AccessConfig.Source.Databasename, tableName }); string statement = $"CREATE TABLE {tableName} ({GetDatabaseStructure(dt, tConnection)});"; createStatements.Add(statement); } return(createStatements.ToArray()); }
private static void Connect2Database() { Console.WriteLine("Connecting to database..."); // Source database connection try { var cfg = AccessConfig.Source; source = Instace[cfg.Kind]; source.Connect(cfg.Host, cfg.Port, cfg.Databasename, cfg.User, cfg.Password); } catch (KeyNotFoundException) { PanicAndExit($"Unsupported Database system: {AccessConfig.Source.Kind}", ExitCode.UnsupportedDatabase); } catch (Exception e) { PanicAndExit($"{e.Message} to source database", ExitCode.SourceConnectionError); } // Target database connection try { var cfg = AccessConfig.Target; target = Instace[cfg.Kind]; target.Connect(cfg.Host, cfg.Port, cfg.Databasename, cfg.User, cfg.Password); } catch (KeyNotFoundException) { PanicAndExit($"Unsupported Database system: {AccessConfig.Target.Kind}", ExitCode.UnsupportedDatabase); } catch (Exception e) { PanicAndExit($"{e.Message} to target database", ExitCode.TargetConnectionError); } Console.WriteLine("Connected to database...\n"); }