スキーマ検出
次のセクションでは、スキーマ情報の取得方法について説明します。
テーブルとビューのリスト
tables メソッドを使用すると、本製品 を通じて利用可能なテーブルとビューを確認できます。これは、クエリのようにカーソルの結果を返します。
cursor.tables()
for (catalog, schema, table, table_type, description) in cursor:
print("Catalog: {}, Schema: {}, Table: {}, Type: {}".format(
catalog, schema, table, table_type
))
columns メソッドを使用すると、テーブルとビューで利用可能なカラムを確認できます。
cursor.columns("Items")
for row in cursor:
print("Name: {}, Type: {}, Length: {}, Precision: {}, Nullable: {}".format(
row[3], row[5], row[6], row[8], row[17]
))