Skip to content

replace_table(tname: str, df: pd.DataFrame)

Marcel Ferrari edited this page Feb 9, 2023 · 1 revision

Replaces the contents of an existing table with the contents of a Pandas DataFrame.

Function

replace_table(tname: str, df: pd.DataFrame) -> None
  • tname: name of the table to replace.
  • df: Pandas DataFrame containing the data to replace the existing table with.

Example

# Connect to database
db = PandaSQLiteDB("example.sql")

# Create a Pandas DataFrame
df = pd.DataFrame({
    'column1': [1, 2, 3],
    'column2': ['G', 'H', 'I']
})

# Replace the contents of an existing table named "my_table"
db.replace_table('my_table', df)