KnowledgeBoat Logo
|

Informatics Practices

The DataFrame SDF stores the sales records of 100 salesmen. Write a program to store this as a table in database namely "company" on MySQL.

Python Pandas

1 Like

Answer

import pandas as pd
from sqlalchemy import create_engine
import pymysql

def sales(sdf):
    engine = create_engine('mysql+pymysql://root:Mypass@localhost/company')
    mycon = engine.connect()
    sdf.to_sql('Records', mycon, if_exists = 'replace', index = False)

Answered By

1 Like


Related Questions