mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 09:54:31 +02:00
db.rename_table() method, refs #565
This commit is contained in:
parent
86a352f8b7
commit
82e8cd3667
3 changed files with 44 additions and 2 deletions
|
|
@ -1279,3 +1279,14 @@ def test_create_transform(fresh_db, cols, kwargs, expected_schema, should_transf
|
|||
new_schema = fresh_db["demo"].schema
|
||||
assert new_schema == expected_schema, repr(new_schema)
|
||||
assert fresh_db["demo"].count == 1
|
||||
|
||||
|
||||
def test_rename_table(fresh_db):
|
||||
fresh_db["t"].insert({"foo": "bar"})
|
||||
assert ["t"] == fresh_db.table_names()
|
||||
fresh_db.rename_table("t", "renamed")
|
||||
assert ["renamed"] == fresh_db.table_names()
|
||||
assert [{"foo": "bar"}] == list(fresh_db["renamed"].rows)
|
||||
# Should error if table does not exist:
|
||||
with pytest.raises(sqlite3.OperationalError):
|
||||
fresh_db.rename_table("does_not_exist", "renamed")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue