Section 6 - Sqlite & MacOS/Mobile/Browsers

Section 6.1 - Opening Sqlite

Example for opening and exploring Sqlite databases.

Example Usage:

$ python opening_sqlite.py history_db

References:

Opening Sqlite configuration

This function shows an example of opening a Sqlite database with Python. Additional information regarding Sqlite modules can be seen at https://docs.python.org/3/library/sqlite3.html.

def open_sqlite(inputdb):
    print("Provided Database: {}".format(inputdb))
    return sqlite3.connect(inputdb)

Listing Tables configuration

This function shows an example of listing available tables in an opened Sqlite database.

def list_tables(conn):
    cur = conn.cursor()
    cur.execute("SELECT name FROM sqlite_master")
    table_list = []
    for i in cur.fetchall():
        table_list.append(i[0])
    
    return table_list

Indices and tables