Skip to content

Instantly share code, notes, and snippets.

@minrk
Created August 21, 2013 14:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save minrk/6295505 to your computer and use it in GitHub Desktop.
"""
list IPython Hub Task History tables, and timestamps
"""
import os
import sqlite3
dbfile = os.path.expanduser("~/.ipython/profile_default/tasks.db")
# connect to
conn = sqlite3.connect(dbfile)
tables = [ r[0] for r in conn.execute("SELECT name from sqlite_master where type = 'table'") ]
# print the timestamp for the last task in each table, and the table name
for table in tables:
c = conn.execute("SELECT submitted from '%s' ORDER by submitted DESC" % table)
last_timestamp = c.next()[0].split('.')[0]
c = conn.execute("SELECT submitted from '%s' ORDER by submitted ASC" % table)
first_timestamp = c.next()[0].split('.')[0]
print "%38s: %s - %s" % (table, first_timestamp, last_timestamp)
# with this info, you can start the Hub with a particular past database name:
# c.SQLiteDB.table = "_u_u_i_d"
@Kameshkk
Copy link

Great! Will give this a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment