# Section 6 - Sqlite & MacOS/Mobile/Browsers — Python Forensics Handbook 20191126 documentation

# Section 6 - Sqlite & MacOS/Mobile/Browsers

## Section 6.1 - Opening Sqlite

Example for opening and exploring Sqlite databased for your command line utility.

Example Usage:

> `$ python opening_sqlite.py history_db`

References:

- https://docs.python.org/3/library/argparse.html

- https://docs.python.org/3/library/os.html

- https://docs.python.org/3/library/sqlite3.html

### 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

- Index

- Module Index

- Search Page