title: Issue with Inserting records through Python into Teradata table
body: <p>I have a project where I am inputting a Terdata DB table name as a parameter, executing a SQL statement that provides aggregates on the table (min, max etc) for every column,  and returns that information where I then put it in a dataframe. 
  What I would like to do is then take the rows that are in the dataframe (1 row per column_name in the table) and insert the results into another DB table 'Data Analysis' where the results will be stored.  </p>
  
  <pre><code>def main():
      def func_1(cfg_tbl):
          udaExec = teradata.UdaExec(appName="DataAnalysis", version="1.0", logConsole=False)
          main_query = """
          SELECT 'SELECT '''
          || TRIM(ColumnName)
          || ''', COUNT(DISTINCT "' || ColumnName || '") AS DISTINCT_COUNT,'
          || ' COUNT(1) - COUNT("' || ColumnName || '") AS NULL_COUNT,'
          || ' MAX("' || ColumnName || '") AS MAX_COL_VALUE,'
          || ' MIN("' || ColumnName || '") AS MIN_COL_VALUE,'
          || CASE WHEN ColumnType IN ('I', 'D', 'F', 'I1', 'I2', 'I8', 'N', 'DA', 'TS') THEN ' MAX(LENGTH(TO_CHAR("' || ColumnName || '")))'
                  WHEN ColumnType IN ('CF', 'CV', 'CO') THEN ' MAX(LENGTH("' || ColumnName || '"))'
                  ELSE NULL END || ' AS MAX_COLUMN_LENGTH,'
          || CASE WHEN ColumnType IN ('I', 'D', 'F', 'I1', 'I2', 'I8', 'N', 'DA', 'TS') THEN ' MIN(LENGTH(TO_CHAR("' || ColumnName || '")))'
                  WHEN ColumnType IN ('CF', 'CV', 'CO') THEN ' MIN(LENGTH("' || ColumnName || '"))'
                  ELSE NULL END || ' AS MIN_COLUMN_LENGTH,'
          || ' COUNT(1) AS TABLE_COUNT,'
          || ' ''%s_%s'' AS TABLE_NM,'
          || ' ''%s'' AS SOURCE_TYPE'
          || ' FROM ' || TRIM(DatabaseName) || '.' || TRIM(TableName) || ';' AS COL
          FROM DBC.ColumnsV A
          WHERE DatabaseName = 'XXX'
          AND TableName = '%s_%s'
          """ % (cfg_pre, cfg_tbl, cfg_src, cfg_pre, cfg_tbl)
          #  connect to Teradata, execute above sql and subsequent SELECT statements
          session = udaExec.connect(method="odbc", dsn="XXXX", username="XXX", password="XXX")
          pd.set_option('max_colwidth', 500)
          df = pd.read_sql(main_query, session)
          sql_execute = list(df.values.flatten())  
          col = ['COLUMN_NAME', 'DISTINCT_COUNT', 'NULL_COUNT', 'MAX_COL_VALUE', 'MIN_COL_VALUE',
          'MAX_COL_LENGTH', 'MIN_COL_LENGTH', 'TABLE_CNT', 'TABLE_NM', 'DATA_SOURCE']
  
          jdf = pd.DataFrame(columns=col)
          for script in sql_execute:
              jdf = pd.read_sql(script, session)
              print(jdf)
              session.execute("""INSERT INTO DATA_ANALYSIS(COLUMN_NM, DISTINCT_COUNT, NULL_COUNT, MAX_COL_VALUE, MIN_COL_VALUE,
                                              MAX_COL_LENGTH, MIN_COL_LENGTH, TABLE_CNT, TABLE_NM, DATA_SOURCE) 
                                              VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (jdf[0], jdf[1], jdf[2], jdf[3], 
                                                                                       jdf[4], jdf[5], jdf[6], jdf[7], jdf[8], jdf[9]))
  </code></pre>
  
  <p>The problem I am facing is with the INSERT code at the bottom.   I am getting a KeyError: 0, I know I must be doing something incorrectly when I am inserting. Any ideas?</p>
  
  <p>The exact error is:</p>
  
  <pre><code>    Traceback (most recent call last):
    File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 2442, in get_loc
      return self._engine.get_loc(key)
    File "pandas\_libs\index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc (pandas\_libs\index.c:5280)
    File "pandas\_libs\index.pyx", line 154, in pandas._libs.index.IndexEngine.get_loc (pandas\_libs\index.c:5126)
    File "pandas\_libs\hashtable_class_helper.pxi", line 1210, in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas\_libs\hashtable.c:20523)
    File "pandas\_libs\hashtable_class_helper.pxi", line 1218, in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas\_libs\hashtable.c:20477)
  KeyError: 0
  </code></pre>