this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Archive tables use _ not -

Tables with hyphens in the name are harder to query
because you have to remember to [escape-them].

+13 -13
+11 -11
tests/test_import.py
··· 25 25 assert 0 == result.exit_code, result.stderr 26 26 db = sqlite_utils.Database(output) 27 27 assert { 28 - "archive-follower", 29 - "archive-saved-search", 30 - "archive-account", 31 - "archive-following", 28 + "archive_follower", 29 + "archive_saved_search", 30 + "archive_account", 31 + "archive_following", 32 32 } == set(db.table_names()) 33 33 34 34 assert [{"accountId": "73747798"}, {"accountId": "386025404"}] == list( 35 - db["archive-follower"].rows 35 + db["archive_follower"].rows 36 36 ) 37 37 assert [{"accountId": "547842573"}, {"accountId": "12158"}] == list( 38 - db["archive-following"].rows 38 + db["archive_following"].rows 39 39 ) 40 40 41 41 assert [ 42 42 {"savedSearchId": "42214", "query": "simonw"}, 43 43 {"savedSearchId": "55814", "query": "django"}, 44 - ] == list(db["archive-saved-search"].rows) 44 + ] == list(db["archive_saved_search"].rows) 45 45 assert [ 46 46 { 47 47 "pk": "c4e32e91742df2331ef3ad1e481d1a64d781183a", ··· 53 53 "createdAt": "2006-11-15T13:18:50.000Z", 54 54 "accountDisplayName": "Simon Willison", 55 55 } 56 - ] == list(db["archive-account"].rows) 56 + ] == list(db["archive_account"].rows) 57 57 58 58 59 59 def test_deletes_existing_archive_tables(import_test_dir): ··· 61 61 output = str(tmpdir / "output.db") 62 62 db = sqlite_utils.Database(output) 63 63 # Create a table 64 - db["archive-foo"].create({"id": int}) 65 - assert ["archive-foo"] == db.table_names() 64 + db["archive_foo"].create({"id": int}) 65 + assert ["archive_foo"] == db.table_names() 66 66 result = CliRunner().invoke(cli.cli, ["import", output, archive]) 67 67 # That table should have been deleted 68 - assert "archive-foo" not in db.table_names() 68 + assert "archive_foo" not in db.table_names()
+2 -2
twitter_to_sqlite/cli.py
··· 518 518 db = sqlite_utils.Database(db_path) 519 519 # Drop archive-* tables that already exist 520 520 for table in db.tables: 521 - if table.name.startswith("archive-"): 521 + if table.name.startswith("archive_"): 522 522 table.drop() 523 523 for filename, content in utils.read_archive_js(archive_path): 524 524 filename = filename[: -len(".js")] ··· 529 529 data = archive.extract_json(content) 530 530 to_insert = transformer(data) 531 531 for table, rows in to_insert.items(): 532 - table_name = "archive-{}".format(table) 532 + table_name = "archive_{}".format(table.replace("-", "_")) 533 533 if pk is not None: 534 534 db[table_name].upsert_all(rows, pk=pk) 535 535 else: