Hi everyone! How do I get `snowflake_multiquery` (...
# ask-community
f
Hi everyone! How do I get
snowflake_multiquery
(https://prefecthq.github.io/prefect-snowflake/database/#prefect_snowflake.database.snowflake_multiquery) to return the column names along with the query result? (The result type is
List[List[Tuple[Any]]]
but it doesn't contain a line for the column names)
Ok that behavior seems to be unrelated to prefect but simply what the snowflake connector api does. I'm using the
pandas
extra to load everything into dataframes instead and that works out fine. If anyone's curious: I'm using my existing snowflake blocks to set up the connection:
Copy code
ctx = snowflake.connector.connect(
        user=snowflake_connector.credentials.user,
        password=snowflake_connector.credentials.password.get_secret_value(),
        account=snowflake_connector.credentials.account,
        warehouse=snowflake_connector.warehouse,
        database=snowflake_connector.database,
        schema=snowflake_connector.schema)

    # Create a cursor object.
    cur = ctx.cursor()

    # Execute a statement that will generate a result set.
    sql = SQL_QUERY_HERE
    cur.execute(sql)

    # Fetch the result set from the cursor and deliver it as the Pandas DataFrame.
    df = cur.fetch_pandas_all()
    print(df)