Skip to main contentSkip to solution

___________ is the default value that indicates a ValueError if the table already exists in the database.

Solution

✅ Correct Option: 3

In pandas, the if_exists parameter of DataFrame.to_sql() decides what happens when the table already exists. Its default value is fail, which raises a ValueError if the table is already present in the database.


replace: drops the existing table, creates it again and inserts the data, so no error is raised.

append: keeps the existing table and adds the new rows to it, so no error is raised.

index: not an if_exists value. It is a separate to_sql() parameter that controls whether the DataFrame index is written as a column.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question