How to call functions with chat models - Database Schema Functions
def get_table_names(conn): 'Return a list of table names' table_names = [] tables = conn.execute('SELECT name FROM sqlite_master WHERE type='table';') for table in tables.fetchall(): table_names.append(table[0]) return table_names def get_column_names(conn, table_name): 'Return a list of column names.' column_names = [] columns = conn.execute(f'PRAGMA table_info({table_name});').fetchall() for col in columns: column_names.append(col[1]) return column_names def get_database_info(conn): 'Return a list of dicts containing the table name and columns for each table in the database' table_dicts = [] for table_name in get_table_names(conn): columns_names = get_column_names(conn, table_name) table_dicts.append({'table_name': table_name, 'column_names': columns_names}) return table_dicts