10. What additional argument do you need to specify in to_sql() so that old data of MySQL table is retained ?
11. If query is string storing an SQL statement. Write statements so that the data is fetched based on query from SQL database Mydata.

Ans 10 :
we can use if_exists = ‘append’ argument to retain old data of table.
Syntax:
<dataframe_object>.to_sql( “table_name”, connection_object, if_exists = “append”)
Example:
df.to_sql(“book”, con, if_exists = “append”)


Ans 11 :
import pandas as pd
import mysql.connector as sqlt
con = sqlt.connect (host = “localhost”, user = “root”, passwd = “yourpassword” , database = “yourdatabasename”)
cursor = con.cursor()
qry = “select * from book;”
df = pd.read_sql(qry, con)
print(df)

error: Content is protected !!