DataFrame and Ad-hoc queries in Snowflake

Created by Will Snell, Modified on Wed, 9 Apr at 2:43 PM by Will Snell

Accessing GDATA Public Analytics via Ad-Hoc Snowflake Queries

Overview

GDATA has worked with Broderick McIntyre to enable ad-hoc query access to public datasets via Snowflake. This guide outlines the steps required to run a basic Snowflake SQL query using Python. The example provided uses Visual Studio Code as the development environment.


Prerequisites

Ensure the following Python packages are installed in your environment:

import snowflake.connector

import pandas as pd

import warnings


warnings.filterwarnings('ignore')


Example Function: Running a Snowflake Query

The following function demonstrates how to connect to the GDATA Snowflake environment and execute a simple query to retrieve data from the public GIS schema.


def get_snowflake():

    connection = snowflake.connector.connect(

        user='your_account_name',

        password='your_password',

        account='ACCOUNT_LOCATOR.gdata.australia-east.azure',

        database='REPORTING'

    )


    query = """

        SELECT *

        FROM GDATA_PUBLIC_ANALYTICS.GIS.GIS_LGA_PLANNING_INFORMATION

        LIMIT 10

    """


    df = pd.read_sql(query, con=connection)

    connection.close()

    return df


Note: You can obtain the appropriate ACCOUNT_LOCATOR by contacting GDATA directly. 


Output

This script retrieves a sample of 10 records from the GIS_LGA_PLANNING_INFORMATION table within the GDATA_PUBLIC_ANALYTICS.GIS schema. You can modify the query string to suit your specific reporting or analytical needs.

Support

For any issues or further assistance, please contact GDATA support. Special thanks to Broderick McIntyre for enabling this integration and supporting the setup process.


If the Data isn't G you need me. 

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article