ODBC Driver for CockroachDB

Build 24.0.9060

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("Orders","defaultdb","public")
for row in cursor:
    print("Name: {}, Type: {}, Length: {}, Precision: {}, Nullable: {}".format(
        row[3], row[5], row[6], row[8], row[17]
    ))

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060