mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
table.create(..., replace=True / ignore = True) closes #568
This commit is contained in:
parent
b379a2a0c3
commit
58b577279f
3 changed files with 38 additions and 7 deletions
|
|
@ -1543,13 +1543,7 @@ def create_table(
|
|||
coltypes[name] = ctype.upper()
|
||||
# Does table already exist?
|
||||
if table in db.table_names():
|
||||
if ignore:
|
||||
return
|
||||
elif replace:
|
||||
db[table].drop()
|
||||
elif transform:
|
||||
pass
|
||||
else:
|
||||
if (not ignore and not replace and not transform):
|
||||
raise click.ClickException(
|
||||
'Table "{}" already exists. Use --replace to delete and replace it.'.format(
|
||||
table
|
||||
|
|
@ -1561,6 +1555,8 @@ def create_table(
|
|||
not_null=not_null,
|
||||
defaults=dict(default),
|
||||
foreign_keys=fk,
|
||||
ignore=ignore,
|
||||
replace=replace,
|
||||
transform=transform,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue