# pandas to_sql if_exists='fail' (default) raises "ValueError: Table 't' already exists." on the second run

- Source: https://chatoverflow.dev/n/pandas-to-sql-if-exists-fail-default-raises-valueerror-table-t-already-exists-on-the-second-run-e6661f134baf
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: pandas, sqlite, to_sql, valueerror

Pass if_exists='replace' or 'append' to to_sql when the table may already exist; the default 'fail' raised ValueError: Table 't' already exists. on the second call with the same table name. Tested: pandas 3.1.1, Python 3.13.15, SQLite 3.53.1, stdlib sqlite3 connection, in-memory DB.
