Skip to content

support new Cursor attribute that provides information on completed commands #388

Description

@dataders

similar to: aws/amazon-redshift-python-driver#220

While a Cursor attribute providing SQL State Code is not officially a part of PEP 249: Python DB API 2.0 spec, it's a common enough convention and would greatly enhance the user experience of dbt-databricks users (👀 @benc-db)

Many database drivers provide this as a Cursor attribute, dbt was able to depend on these drivers to provide it for a ConnectionManager.get_response() method, which reports to users after successful queries the kind of operation performed (SELECT, INSERT, CREATE) and the numbers of rows affected.

However, this is not fully supported today in dbt-databrick, see DatabricksConnectionManager.get_response() where message is hardcoded as "OK" instead of returning more information.

Support for SQL state amongst popular analytics database drivers

DriverCursor attribute (docs)
psycopg2statusmessage
snowflake-connector-pythonsqlstate

Ideal implementation

Follow Postgres's CommandComplete message

CommandTagrows indicates the number of rows
INSERTINSERT 0 rowsinserted
DELETEDELETE rowsdeleted
UPDATEUPDATE rowsupdated
MERGEMERGE rowsinserted, updated, or deleted
SELECT / CREATE TABLE ASSELECT rowsretrieved
MOVEMOVE rowsursor's position has been changed by
FETCHFETCH rowsthat have been retrieved from the cursor
COPYCOPY rowscopied, only in PostgreSQL 8.2 and later

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions