File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -567,6 +567,17 @@ If you want to ensure that every foreign key column in your database has a corre
567567
568568 db.index_foreign_keys()
569569
570+ .. _python_api_drop:
571+
572+ Dropping a table
573+ ================
574+
575+ You can drop a table by using the `` .drop()`` method:
576+
577+ .. code- block:: python
578+
579+ db[" my_table" ].drop()
580+
570581.. _python_api_hash:
571582
572583Setting an ID based on the hash of the row contents
Original file line number Diff line number Diff line change @@ -621,7 +621,7 @@ def add_column(
621621 return self
622622
623623 def drop (self ):
624- return self .db .conn .execute ("DROP TABLE {}" .format (self .name ))
624+ self .db .conn .execute ("DROP TABLE {}" .format (self .name ))
625625
626626 def guess_foreign_table (self , column ):
627627 column = column .lower ()
Original file line number Diff line number Diff line change @@ -775,3 +775,10 @@ def test_cannot_provide_both_filename_and_memory():
775775def test_creates_id_column (fresh_db ):
776776 last_pk = fresh_db .table ("cats" , pk = "id" ).insert ({"name" : "barry" }).last_pk
777777 assert [{"name" : "barry" , "id" : last_pk }] == list (fresh_db ["cats" ].rows )
778+
779+
780+ def test_drop (fresh_db ):
781+ fresh_db ["t" ].insert ({"foo" : 1 })
782+ assert ["t" ] == fresh_db .table_names ()
783+ assert None is fresh_db ["t" ].drop ()
784+ assert [] == fresh_db .table_names ()
You can’t perform that action at this time.
0 commit comments