{"html_url": "https://github.com/simonw/sqlite-utils/issues/268#issuecomment-859898736", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/268", "id": 859898736, "node_id": "MDEyOklzc3VlQ29tbWVudDg1OTg5ODczNg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-11T20:37:44Z", "updated_at": "2021-06-11T20:37:44Z", "author_association": "OWNER", "body": "From the prototype:\r\n```\r\n% sqlite-utils schema 24ways.db\r\nCREATE TABLE [articles] (\r\n [title] TEXT ,\r\n [contents] TEXT ,\r\n [year] TEXT ,\r\n [author] TEXT ,\r\n [author_slug] TEXT ,\r\n [published] TEXT ,\r\n [url] TEXT ,\r\n [topic] TEXT \r\n );\r\nCREATE VIRTUAL TABLE \"articles_fts\" USING FTS5 (\r\n title, author, contents,\r\n content=\"articles\"\r\n );\r\nCREATE TABLE 'articles_fts_data'(id INTEGER PRIMARY KEY, block BLOB);\r\nCREATE TABLE 'articles_fts_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID;\r\nCREATE TABLE 'articles_fts_docsize'(id INTEGER PRIMARY KEY, sz BLOB);\r\nCREATE TABLE 'articles_fts_config'(k PRIMARY KEY, v) WITHOUT ROWID;\r\n% sqlite-utils schema 24ways.db | sqlite3 /tmp/boo.db\r\nError: near line 15: table 'articles_fts_data' already exists\r\nError: near line 16: table 'articles_fts_idx' already exists\r\nError: near line 17: table 'articles_fts_docsize' already exists\r\nError: near line 18: table 'articles_fts_config' already exists\r\n```\r\nThe problem here is that the `CREATE VIRTUAL TABLE \"articles_fts\"...` line causes those next four tables to be created - but that means that piping the output of this command into `sqlite3` in order to re-create those tables throws errors.\r\n\r\nI don't think this matters. I see this tool as more for introspection than for recreating table structures.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 919181559, "label": "db.schema property and sqlite-utils schema command"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/268#issuecomment-859895540", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/268", "id": 859895540, "node_id": "MDEyOklzc3VlQ29tbWVudDg1OTg5NTU0MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-11T20:30:34Z", "updated_at": "2021-06-11T20:30:34Z", "author_association": "OWNER", "body": "You can currently see the `sql` on the CLI using:\r\n\r\n % sqlite-utils rows fixtures.db sqlite_master -c name -c sql\r\n name sql\r\n -------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n simple_primary_key CREATE TABLE simple_primary_key (\r\n id varchar(30) primary key,\r\n content text\r\n )\r\n sqlite_autoindex_simple_primary_key_1\r\n primary_key_multiple_columns CREATE TABLE primary_key_multiple_columns (\r\n id varchar(30) primary key,\r\n content text,\r\n content2 text\r\n )\r\n sqlite_autoindex_primary_key_multiple_columns_1\r\n primary_key_multiple_columns_explicit_label CREATE TABLE primary_key_multiple_columns_explicit_label (\r\n id varchar(30) primary key,\r\n content text,\r\n content2 text\r\n )\r\n sqlite_autoindex_primary_key_multiple_columns_explicit_label_1\r\n compound_primary_key CREATE TABLE compound_primary_key (\r\n pk1 varchar(30),\r\n pk2 varchar(30),\r\n content text,\r\n PRIMARY KEY (pk1, pk2)\r\n )\r\n sqlite_autoindex_compound_primary_key_1\r\n compound_three_primary_keys CREATE TABLE compound_three_primary_keys (\r\n pk1 varchar(30),\r\n pk2 varchar(30),\r\n pk3 varchar(30),\r\n content text,\r\n PRIMARY KEY (pk1, pk2, pk3)\r\n )\r\n sqlite_autoindex_compound_three_primary_keys_1\r\n foreign_key_references CREATE TABLE foreign_key_references (\r\n pk varchar(30) primary key,\r\n foreign_key_with_label varchar(30),\r\n foreign_key_with_no_label varchar(30),\r\n FOREIGN KEY (foreign_key_with_label) REFERENCES simple_primary_key(id),\r\n FOREIGN KEY (foreign_key_with_no_label) REFERENCES primary_key_multiple_columns(id)\r\n )\r\n sqlite_autoindex_foreign_key_references_1\r\n sortable CREATE TABLE sortable (\r\n pk1 varchar(30),\r\n pk2 varchar(30),\r\n content text,\r\n sortable integer,\r\n sortable_with_nulls real,\r\n sortable_with_nulls_2 real,\r\n text text,\r\n PRIMARY KEY (pk1, pk2)\r\n )\r\n sqlite_autoindex_sortable_1\r\n no_primary_key CREATE TABLE no_primary_key (\r\n content text,\r\n a text,\r\n b text,\r\n c text\r\n )\r\n 123_starts_with_digits CREATE TABLE [123_starts_with_digits] (\r\n content text\r\n )\r\n paginated_view CREATE VIEW paginated_view AS\r\n SELECT\r\n content,\r\n '- ' || content || ' -' AS content_extra\r\n FROM no_primary_key\r\n Table With Space In Name CREATE TABLE \"Table With Space In Name\" (\r\n pk varchar(30) primary key,\r\n content text\r\n )\r\n sqlite_autoindex_Table With Space In Name_1\r\n table/with/slashes.csv CREATE TABLE \"table/with/slashes.csv\" (\r\n pk varchar(30) primary key,\r\n content text\r\n )\r\n sqlite_autoindex_table/with/slashes.csv_1\r\n complex_foreign_keys CREATE TABLE \"complex_foreign_keys\" (\r\n pk varchar(30) primary key,\r\n f1 text,\r\n f2 text,\r\n f3 text,\r\n FOREIGN KEY (\"f1\") REFERENCES [simple_primary_key](id),\r\n FOREIGN KEY (\"f2\") REFERENCES [simple_primary_key](id),\r\n FOREIGN KEY (\"f3\") REFERENCES [simple_primary_key](id)\r\n )\r\n sqlite_autoindex_complex_foreign_keys_1\r\n custom_foreign_key_label CREATE TABLE \"custom_foreign_key_label\" (\r\n pk varchar(30) primary key,\r\n foreign_key_with_custom_label text,\r\n FOREIGN KEY (\"foreign_key_with_custom_label\") REFERENCES [primary_key_multiple_columns_explicit_label](id)\r\n )\r\n sqlite_autoindex_custom_foreign_key_label_1\r\n units CREATE TABLE units (\r\n pk integer primary key,\r\n distance int,\r\n frequency int\r\n )\r\n searchable CREATE TABLE searchable (\r\n pk integer primary key,\r\n text1 text,\r\n text2 text,\r\n [name with . and spaces] text\r\n )\r\n searchable_fts CREATE VIRTUAL TABLE \"searchable_fts\"\r\n USING FTS3 (text1, text2, [name with . and spaces], content=\"searchable\")\r\n searchable_fts_content CREATE TABLE 'searchable_fts_content'(docid INTEGER PRIMARY KEY, 'c0text1', 'c1text2', 'c2name with . and spaces', 'c3content')\r\n searchable_fts_segments CREATE TABLE 'searchable_fts_segments'(blockid INTEGER PRIMARY KEY, block BLOB)\r\n searchable_fts_segdir CREATE TABLE 'searchable_fts_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx))\r\n sqlite_autoindex_searchable_fts_segdir_1\r\n select CREATE TABLE [select] (\r\n [group] text,\r\n [having] text,\r\n [and] text\r\n )\r\n facet_cities CREATE TABLE facet_cities (\r\n id integer primary key,\r\n name text\r\n )\r\n simple_view CREATE VIEW simple_view AS\r\n SELECT content, upper(content) AS upper_content FROM simple_primary_key\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 919181559, "label": "db.schema property and sqlite-utils schema command"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/268#issuecomment-859894105", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/268", "id": 859894105, "node_id": "MDEyOklzc3VlQ29tbWVudDg1OTg5NDEwNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-11T20:28:52Z", "updated_at": "2021-06-11T20:28:52Z", "author_association": "OWNER", "body": "Out of interest, here are the rows from that table where `sql` is `null`: https://latest.datasette.io/fixtures?sql=select%0D%0A++*%0D%0Afrom%0D%0A++sqlite_master%0D%0Awhere%0D%0A++sql+is+null\r\n\r\n```csv\r\ntype,name,tbl_name,rootpage,sql\r\nindex,sqlite_autoindex_simple_primary_key_1,simple_primary_key,3,\r\nindex,sqlite_autoindex_primary_key_multiple_columns_1,primary_key_multiple_columns,5,\r\nindex,sqlite_autoindex_primary_key_multiple_columns_explicit_label_1,primary_key_multiple_columns_explicit_label,7,\r\nindex,sqlite_autoindex_compound_primary_key_1,compound_primary_key,9,\r\nindex,sqlite_autoindex_compound_three_primary_keys_1,compound_three_primary_keys,11,\r\nindex,sqlite_autoindex_foreign_key_references_1,foreign_key_references,14,\r\nindex,sqlite_autoindex_sortable_1,sortable,16,\r\nindex,sqlite_autoindex_Table With Space In Name_1,Table With Space In Name,20,\r\nindex,sqlite_autoindex_table/with/slashes.csv_1,table/with/slashes.csv,22,\r\nindex,sqlite_autoindex_complex_foreign_keys_1,complex_foreign_keys,24,\r\nindex,sqlite_autoindex_custom_foreign_key_label_1,custom_foreign_key_label,26,\r\nindex,sqlite_autoindex_tags_1,tags,31,\r\nindex,sqlite_autoindex_searchable_tags_1,searchable_tags,34,\r\nindex,sqlite_autoindex_searchable_fts_segdir_1,searchable_fts_segdir,37,\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 919181559, "label": "db.schema property and sqlite-utils schema command"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/268#issuecomment-859888469", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/268", "id": 859888469, "node_id": "MDEyOklzc3VlQ29tbWVudDg1OTg4ODQ2OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-06-11T20:26:20Z", "updated_at": "2021-06-11T20:26:20Z", "author_association": "OWNER", "body": "`sqlite-utils schema data.db` could output the same thing to the console.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 919181559, "label": "db.schema property and sqlite-utils schema command"}, "performed_via_github_app": null}