Using the engine in place of the raw_connection()
worked:
import pandas as pd
import mysql.connector
from sqlalchemy import create_engine
engine = create_engine('mysql+mysqlconnector://[user]:[pass]@[host]:[port]/[schema]', echo=False)
data.to_sql(name="sample_table2", con=engine, if_exists="append", index=False)
Not clear on why when I tried this yesterday it gave me the earlier error.