MCPcopy
hub / github.com/pandas-dev/pandas / test_api_to_sql_replace

Function test_api_to_sql_replace

pandas/tests/io/test_sql.py:1647–1661  ·  view source on GitHub ↗
(conn, request, test_frame1)

Source from the content-addressed store, hash-verified

1645
1646@pytest.mark.parametrize("conn", all_connectable)
1647def test_api_to_sql_replace(conn, request, test_frame1):
1648 conn = request.getfixturevalue(conn)
1649 if sql.has_table("test_frame3", conn):
1650 with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL:
1651 pandasSQL.drop_table("test_frame3")
1652
1653 sql.to_sql(test_frame1, "test_frame3", conn, if_exists="fail")
1654 # Add to table again
1655 sql.to_sql(test_frame1, "test_frame3", conn, if_exists="replace")
1656 assert sql.has_table("test_frame3", conn)
1657
1658 num_entries = len(test_frame1)
1659 num_rows = count_rows(conn, "test_frame3")
1660
1661 assert num_rows == num_entries
1662
1663
1664@pytest.mark.parametrize("conn", all_connectable)

Callers

nothing calls this directly

Calls 4

count_rowsFunction · 0.85
has_tableMethod · 0.45
drop_tableMethod · 0.45
to_sqlMethod · 0.45

Tested by

no test coverage detected