mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 17:34:32 +02:00
Also made it so .duplicate() raises new NoTable exception rather than raising an AssertionError if the source table does not exist.
This commit is contained in:
parent
da030d49fd
commit
c710ade644
7 changed files with 80 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from ast import Not
|
||||
from .utils import (
|
||||
chunks,
|
||||
hash_record,
|
||||
|
|
@ -224,6 +225,11 @@ class NoObviousTable(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class NoTable(Exception):
|
||||
"Specified table does not exist"
|
||||
pass
|
||||
|
||||
|
||||
class BadPrimaryKey(Exception):
|
||||
"Table does not have a single obvious primary key"
|
||||
pass
|
||||
|
|
@ -1482,7 +1488,8 @@ class Table(Queryable):
|
|||
|
||||
:param new_name: Name of the new table
|
||||
"""
|
||||
assert self.exists()
|
||||
if not self.exists():
|
||||
raise NoTable(f"Table {self.name} does not exist")
|
||||
with self.db.conn:
|
||||
sql = "CREATE TABLE [{new_table}] AS SELECT * FROM [{table}];".format(
|
||||
new_table=new_name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue