simonw / db-to-sqlite

CLI tool for exporting tables or queries from any SQL database to a SQLite file
Apache License 2.0
368 stars 28 forks source link

Add a progress bar to --all #7

Closed simonw closed 5 years ago

simonw commented 5 years ago

I can use Click's built-in progress bar for this.

simonw commented 5 years ago

First attempt at this (no progress bars yet):

$ db-to-sqlite /tmp/simon.db --connection="postgresql://localhost/simonwillisonblog" -p --all --skip=django_admin_log
1/23: auth_user_user_permissions
2/23: blog_comment
3/23: blog_photo
4/23: blog_blogmark
5/23: blog_photoset
6/23: auth_group
7/23: auth_user_groups
8/23: auth_user
9/23: blog_entry
10/23: blog_entry_tags
11/23: blog_photoset_photos
12/23: blog_quotation_tags
13/23: django_migrations
14/23: django_session
15/23: django_content_type
16/23: blog_tag
17/23: feedstats_subscribercount
18/23: redirects_redirect
19/23: auth_permission
20/23: auth_group_permissions
21/23: blog_blogmark_tags
22/23: django_admin_log
  ... skipping
23/23: blog_quotation

Adding 7 foreign keys
  blog_entry_tags.entry_id => blog_entry.id
  blog_entry_tags.tag_id => blog_tag.id
  blog_quotation_tags.quotation_id => blog_quotation.id
  blog_quotation_tags.tag_id => blog_tag.id
  auth_permission.content_type_id => django_content_type.id
  blog_blogmark_tags.blogmark_id => blog_blogmark.id
  blog_blogmark_tags.tag_id => blog_tag.id
simonw commented 5 years ago

Now shows progress bar for individual tables, but only if they take long enough for it to be worthwhile (Click handles that automatically):

15/23: django_content_type
16/23: blog_tag
17/23: feedstats_subscribercount
  [####################################]  100%
18/23: redirects_redirect