def pdf2cte(terms_table, table_name):
    """Generate SQL code to represent Pandas DataFrame as a Common Table Expression"""
    quotify = lambda c: c  # '[' + c + ']'
    row2tuple_str = lambda row: '(' + ', '.join([ f"'{x}'" if (isinstance(x, str) or isinstance(x, bool)) else str(x) 
                                                 for x in row ]) + ')'
    cte_strings = []
    colnames_str = ', '.join([quotify(c) for c in terms_table.columns])
    tuple_strings = terms_table.apply(row2tuple_str, axis=1)
    tuples = ',\n\t\t'.join([ts for ts in tuple_strings])
    cte_strings.append( f"{table_name} ({colnames_str}) as\n\t(VALUES\n\t\t{tuples}\n\t)" )
    return ',\n'.join(cte_strings)