title: TypeError - Attempting to SQL Insert : sequence item 0: expected str instance, dict found
body: <p>I have a fairly large pandas DataFrame that I am attempting to <code>INSERT</code> into a <code>MySQL</code> table.</p>
  <pre><code>import pandas as pd 
  
  # mysql connection
  import pymysql
  from sqlalchemy import create_engine
  user = 'user'
  pwd = 'xxxxx'
  host =  'x.com'
  port = 3306
  database = 'dbname'
  
  engine = create_engine(&quot;mysql+pymysql://{}:{}@{}/{}&quot;.format(user,pwd,host,database))
  
  
  # column dtypes
  [
    dtype('O'),
    dtype('O'),
    dtype('O'),
    dtype('int64'),
    dtype('float64'),
    dtype('float64'),
    dtype('O'),
    dtype('O')
  ]
  </code></pre>
  <p>Here are the steps I take for <code>dict</code> to <code>str</code>:</p>
  <pre><code># Find columns containing dicts
  col_dict = [i for i in df.columns if isinstance(df[i][0],dict)]
  print(col_dict)
  [] &lt;-- empty list
  </code></pre>
  <p>I checked the datatype of columns itself, not the data and it's all <code>&lt;class 'str'&gt;</code>.</p>
  <pre><code>col_type = [type(i) for i in df.columns] print(col_dict)
  
  # Dict to string
  df[col_dict] = df[col_dict].astype(str)
  
  # Insert into SQL
  con = engine.connect()
  df.to_sql(name=&quot;df_table&quot;, con=con, if_exists = 'replace')
  con.close()
  </code></pre>
  <p>Traceback:</p>
  <pre><code>/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pymysql/converters.py in escape_item(val, charset, mapping)
       21 
       22     if encoder in (escape_dict, escape_sequence):
  ---&gt; 23         val = encoder(val, charset, mapping)
       24     else:
       25         val = encoder(val, mapping)
  
  /Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pymysql/converters.py in escape_dict(val, charset, mapping)
       30     n = {}
       31     for k, v in val.items():
  ---&gt; 32         quoted = escape_item(v, charset, mapping)
       33         n[k] = quoted
       34     return n
  
  /Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pymysql/converters.py in escape_item(val, charset, mapping)
       21 
       22     if encoder in (escape_dict, escape_sequence):
  ---&gt; 23         val = encoder(val, charset, mapping)
       24     else:
       25         val = encoder(val, mapping)
  
  /Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pymysql/converters.py in escape_sequence(val, charset, mapping)
       40         quoted = escape_item(item, charset, mapping)
       41         n.append(quoted)
  ---&gt; 42     return &quot;(&quot; + &quot;,&quot;.join(n) + &quot;)&quot;
       43 
       44 
  
  TypeError: sequence item 0: expected str instance, dict found
  </code></pre>