Q. What is the difference between following two statements?
(i)
df.to_sql('houses', con = conn, if_exists = 'replace')
(ii)
df.to_sql('houses', con = conn, if_exists = 'replace', index = False)
Answer =
(i)
It converting a dataframe to SQL table
It creates SQL table ‘houses’
If ‘houses’ table exists then this code statement replace the table, this statement creates index column.
(ii)
It also converting a dataframe to SQL table
It creates SQL table ‘houses’
If ‘houses’ table exists then this code statement replace the table, this statement does not creates index column.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )