Forums

Full Version: How to write data to a sql table using python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Use python script component.
Paste below script in meta information script section.
Provide connection credentials.

import pandas as pd
from sqlalchemy import create_engine
def sql_write(data):

   # Connect to the database
   engine = create_engine('mysql+pymysql://user:password@host/database')

   # Store the data in the database
   data.to_sql('table_name', engine, if_exists='replace')