def print_db(database):
    if PY3:
        # On PY3, connect() only accepts unicode
        conn = sqlite3.connect(str(database))
    else:
        conn = sqlite3.connect(database.path)
    conn.row_factory = sqlite3.Row
    conn.text_factory = lambda x: unicode_(x, 'utf-8', 'replace')

    cur = conn.cursor()
    processes = cur.execute(
        '''
        SELECT id, parent, timestamp, exit_timestamp, exitcode, cpu_time
        FROM processes;
        ''')
    print("\nProcesses:")
    header = ("+------+--------+-------+------------------+------------------+"
              "----------+")
    print(header)
    print("|  id  | parent |  exit |     timestamp    |  exit timestamp  |"
          " cpu time |")
    print(header)
    for (r_id, r_parent, r_timestamp, r_endtime,
            r_exit, r_cpu_time) in processes:
        f_id = "{0: 5d} ".format(r_id)
        if r_parent is not None:
            f_parent = "{0: 7d} ".format(r_parent)
        else:
            f_parent = "        "
        if r_exit & 0x0100:
            f_exit = " sig{0: <2d} ".format(r_exit)
        else:
            f_exit = "    {0: <2d} ".format(r_exit)
        f_timestamp = "{0: 17d} ".format(r_timestamp)
        f_endtime = "{0: 17d} ".format(r_endtime)
        if r_cpu_time >= 0:
            f_cputime = "{0: 9.2f} ".format(r_cpu_time * 0.001)
        else:
            f_cputime = "          "
        print('|'.join(('', f_id, f_parent, f_exit,
                        f_timestamp, f_endtime, f_cputime, '')))
        print(header)
    cur.close()

    cur = conn.cursor()
    processes = cur.execute(
        '''
        SELECT id, name, timestamp, process, argv
        FROM executed_files;
        ''')
    print("\nExecuted files:")
    header = ("+--------+------------------+---------+------------------------"
              "---------------+")
    print(header)
    print("|   id   |     timestamp    | process | name and argv              "
          "           |")
    print(header)
    for r_id, r_name, r_timestamp, r_process, r_argv in processes:
        f_id = "{0: 7d} ".format(r_id)
        f_timestamp = "{0: 17d} ".format(r_timestamp)
        f_proc = "{0: 8d} ".format(r_process)
        argv = r_argv.split('\0')
        if not argv[-1]:
            argv = argv[:-1]
        cmdline = ' '.join(shell_escape(a) for a in argv)
        if argv[0] not in (r_name, os.path.basename(r_name)):
            cmdline = "(%s) %s" % (shell_escape(r_name), cmdline)
        f_cmdline = " {0: <37s} ".format(cmdline)
        print('|'.join(('', f_id, f_timestamp, f_proc, f_cmdline, '')))
        print(header)
    cur.close()

    cur = conn.cursor()
    processes = cur.execute(
        '''
        SELECT id, name, timestamp, mode, process
        FROM opened_files;
        ''')
    print("\nFiles:")
    header = ("+--------+------------------+---------+------+-----------------"
              "---------------+")
    print(header)
    print("|   id   |     timestamp    | process | mode | name                "
          "           |")
    print(header)
    for r_id, r_name, r_timestamp, r_mode, r_process in processes:
        f_id = "{0: 7d} ".format(r_id)
        f_timestamp = "{0: 17d} ".format(r_timestamp)
        f_proc = "{0: 8d} ".format(r_process)
        f_mode = "{0: 5d} ".format(r_mode)
        f_name = " {0: <30s} ".format(r_name)
        print('|'.join(('', f_id, f_timestamp, f_proc, f_mode, f_name, '')))
        print(header)
    cur.close()

    cur = conn.cursor()
    connections = cur.execute(
        '''
        SELECT DISTINCT inbound, family, protocol, address
        FROM connections
        ORDER BY inbound, family, timestamp;
        ''')
    header_shown = -1
    current_family = current_protocol = None
    for r_inbound, r_family, r_protocol, r_address in connections:
        if header_shown < r_inbound:
            if r_inbound:
                print("\nIncoming connections:")
            else:
                print("\nRemote connections:")
            header_shown = r_inbound
            current_family = None
        if current_family != r_family:
            print("    %s" % r_family)
            current_family = r_family
            current_protocol = None
        if current_protocol != r_protocol:
            print("      %s" % r_protocol)
            current_protocol = r_protocol
        print("        %s" % r_address)

    conn.close()
Remove a record from the DB.
dataset/ETHPy150Open ViDA-NYU/reprozip/reprozip/reprozip/main.py/print_db--crossover with--dataset/ETHPy150Open ipython/ipython-py3k/IPython/parallel/controller/sqlitedb.py/SQLiteDB.drop_matching_records