mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
add-column col_type now optional, defaults to str
This commit is contained in:
parent
557dc3f9a7
commit
3cab079d3e
6 changed files with 18 additions and 8 deletions
|
|
@ -148,6 +148,7 @@ def optimize(path, no_vacuum):
|
|||
type=click.Choice(
|
||||
["integer", "float", "blob", "text", "INTEGER", "FLOAT", "BLOB", "TEXT"]
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
def add_column(path, table, col_name, col_type):
|
||||
"Add a column to the specified table"
|
||||
|
|
|
|||
|
|
@ -276,7 +276,9 @@ class Table:
|
|||
self.db.conn.execute(sql)
|
||||
return self
|
||||
|
||||
def add_column(self, col_name, col_type):
|
||||
def add_column(self, col_name, col_type=None):
|
||||
if col_type is None:
|
||||
col_type = str
|
||||
sql = "ALTER TABLE [{table}] ADD COLUMN [{col_name}] {col_type};".format(
|
||||
table=self.name, col_name=col_name, col_type=COLUMN_TYPE_MAPPING[col_type]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue