Skip to content

In python, Unable to set default catalog in FlightSQL connection using ADBC driver #48

@sairamkrish

Description

@sairamkrish

In python client to gizmoSQL server, I am unable to set default catalog in FlightSQL connection using ADBC driver.
Without this, it complicates the queries as we have to specify the catalog in every query.
Is there a way to set the default catalog for the connection?
In following python code snippet, we explore different options that I tried to set the default catalog and the results of those attempts.

import os
from adbc_driver_flightsql import dbapi as gizmosql, DatabaseOptions


with gizmosql.connect(uri="grpc+tls://localhost:31337",
  db_kwargs={"username": os.getenv("GIZMOSQL_USERNAME", "gizmosql_username"),
              "password": os.getenv("GIZMOSQL_PASSWORD", "gizmosql_password"),
              DatabaseOptions.TLS_SKIP_VERIFY.value: "true"  # Not needed if you use a trusted CA-signed TLS cert

              },
  # Option 1: Failed with "[FlightSQL] SetSessionOptions not implemented"
  # conn_kwargs={
  #     "adbc.connection.catalog": "catalog_1",
  # },

) as conn:
  with conn.cursor() as cur:
    # Option 2: failed setting the catalog directly on the connection object - Failed with "[FlightSQL] SetSessionOptions not implemented"
    # conn.adbc_current_catalog = "catalog_1"

    # Option 3: Works., But for every query we have to execute this before
    cur.execute("USE catalog_1")
    cur.execute("SELECT my_col_1 FROM my_table_in_catalog_1")

This would help anyone that has python stack & attempting to use GizmoSQL server with ADBC driver.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions