mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 18:04:32 +02:00
db.schema and 'sqlite-utils schema' command, closes #268
This commit is contained in:
parent
9696abfabf
commit
0d2e4f49f3
6 changed files with 90 additions and 2 deletions
|
|
@ -1916,6 +1916,33 @@ def test_triggers(tmpdir, extra_args, expected):
|
|||
assert result.output == expected
|
||||
|
||||
|
||||
def test_schema(tmpdir):
|
||||
db_path = str(tmpdir / "test.db")
|
||||
db = Database(db_path)
|
||||
db["dogs"].create({"id": int, "name": str})
|
||||
db["chickens"].create({"id": int, "name": str, "breed": str})
|
||||
db["chickens"].create_index(["breed"])
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
["schema", db_path],
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert result.output == (
|
||||
"CREATE TABLE [dogs] (\n"
|
||||
" [id] INTEGER,\n"
|
||||
" [name] TEXT\n"
|
||||
");\n"
|
||||
"CREATE TABLE [chickens] (\n"
|
||||
" [id] INTEGER,\n"
|
||||
" [name] TEXT,\n"
|
||||
" [breed] TEXT\n"
|
||||
");\n"
|
||||
"CREATE INDEX [idx_chickens_breed]\n"
|
||||
" ON [chickens] ([breed]);\n"
|
||||
)
|
||||
|
||||
|
||||
def test_long_csv_column_value(tmpdir):
|
||||
db_path = str(tmpdir / "test.db")
|
||||
csv_path = str(tmpdir / "test.csv")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue