mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Initial implementation of create-table command, refs #27
This commit is contained in:
parent
79541d3a6d
commit
36d256b047
2 changed files with 67 additions and 0 deletions
|
|
@ -861,3 +861,39 @@ def test_upsert_alter(db_path, tmpdir):
|
|||
assert [{"id": 1, "name": "Cleo", "age": 5},] == db.execute_returning_dicts(
|
||||
"select * from dogs order by id"
|
||||
)
|
||||
|
||||
|
||||
def test_create_table():
|
||||
runner = CliRunner()
|
||||
with runner.isolated_filesystem():
|
||||
result = runner.invoke(
|
||||
cli.cli,
|
||||
[
|
||||
"create-table",
|
||||
"test.db",
|
||||
"t",
|
||||
"id",
|
||||
"integer",
|
||||
"name",
|
||||
"text",
|
||||
"age",
|
||||
"integer",
|
||||
"weight",
|
||||
"float",
|
||||
"thumbnail",
|
||||
"blob",
|
||||
"--pk",
|
||||
"id",
|
||||
],
|
||||
)
|
||||
assert 0 == result.exit_code
|
||||
db = Database("test.db")
|
||||
assert (
|
||||
"CREATE TABLE [t] (\n"
|
||||
" [id] INTEGER PRIMARY KEY,\n"
|
||||
" [name] TEXT,\n"
|
||||
" [age] INTEGER,\n"
|
||||
" [weight] FLOAT,\n"
|
||||
" [thumbnail] BLOB\n"
|
||||
")"
|
||||
) == db["t"].schema
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue