from typing import Dict
from typing import List


def get_sqlite_table_columns(conn) -> Dict[str, List[str]]:
    """
    Retrieves a dictionary mapping table names to a list of all the columns for that table
    where the columns are in ordinal value.
    Args:
        conn: The database connection.

    Returns: A dictionary of the form { table_name: [col_name1, col_name2...col_nameN] }

    """
    cur = conn.cursor()
    cur.execute("SELECT name FROM sqlite_master tables WHERE tables.type='table'")
    tables = list([table[0] for table in cur.fetchall()])
    cur.close()

    to_ret = {}
    for table in tables:
        cur = conn.cursor()
        cur.execute('SELECT name FROM pragma_table_info(?) ORDER BY cid', [table])
        to_ret[table] = list([col[0] for col in cur.fetchall()])

    return to_ret