public static void Import( IReadOnlyList <string> srcColNames, IEnumerable <object[]> dataRows, Ast.ImportTable importTable, bool temporaryTable, bool truncateExistingTable, bool stopAtFirstBlankRow, IfConversionFails ifConversionFails, BlankValuesOption blankValuesMethod, Notebook notebook, ScriptRunner runner, ScriptEnv env ) { var dstTableName = runner.EvaluateIdentifierOrExpr(importTable.TableName, env); var mappings = GetImportColumnMappings(importTable.ImportColumns, runner, env, srcColNames); if (!mappings.Any()) { throw new Exception("No columns chosen for import."); } CreateOrTruncateTable(mappings, dstTableName, temporaryTable, truncateExistingTable, notebook); VerifyColumnsExist(mappings.Select(x => x.DstColumnName), dstTableName, notebook); InsertDataRows(dataRows, srcColNames, mappings, dstTableName, ifConversionFails, stopAtFirstBlankRow, blankValuesMethod, notebook); }
private Ast.ImportTable ParseImportTable(TokenQueue q) { var n = new Ast.ImportTable { SourceToken = q.SourceToken }; n.TableName = Check(q, ParseIdentifierOrExpr(q)); if (q.Peek() == "(") { q.Take("("); do { n.ImportColumns.Add(Check(q, ParseImportColumn(q))); } while (q.TakeMaybe(",")); q.Take(")"); } return(n); }
public static void Import(string[] srcColNames, IEnumerable <object[]> dataRows, Ast.ImportTable importTable, bool temporaryTable, bool truncateExistingTable, IfConversionFails ifConversionFails, INotebook notebook, ScriptRunner runner, ScriptEnv env) { Ast.ImportColumn[] dstColNodes; string[] dstColNames; var dstTableName = runner.EvaluateIdentifierOrExpr(importTable.TableName, env); GetDestinationColumns(importTable.ImportColumns, runner, env, srcColNames, out dstColNodes, out dstColNames); CreateOrTruncateTable(srcColNames, dstColNodes, dstColNames, dstTableName, temporaryTable, truncateExistingTable, notebook); VerifyColumnsExist(dstColNames, dstTableName, notebook); InsertDataRows(dataRows, dstColNames, dstColNodes, dstTableName, ifConversionFails, notebook); }