Discovering Schemas
The following sections show how to obtain schema information.
List Tables and Views
You can use the tables method to discover what tables and views are available through the driver. This returns results on the cursor like a query would.
cursor.tables() for (catalog, schema, table, table_type, description) in cursor: print("Catalog: {}, Schema: {}, Table: {}, Type: {}".format( catalog, schema, table, table_type ))
You can use the columns method to discover what columns are available on a table or view.
cursor.columns("Customer","AdventureWorksDW2012Multidimensional-SE","Adventure Works") for row in cursor: print("Name: {}, Type: {}, Length: {}, Precision: {}, Nullable: {}".format( row[3], row[5], row[6], row[8], row[17] ))