Title: | Query 'Snowflake' Databases with 'SQL' |
---|---|
Description: | A wrapper allowing 'SQL' queries to be run on a 'Snowflake' instance directly from an 'R' script, by using the 'snowflake-connector-python' package in the background. |
Authors: | Dani Mermelstein [aut, cre, cph] |
Maintainer: | Dani Mermelstein <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.2.1 |
Built: | 2025-03-01 04:21:11 UTC |
Source: | https://github.com/mermelstein/snowquery |
Run a SQL query on a Snowflake, Redshift or Postgres database and return the results as a data frame. See the snowquery README for more information on how to pass in your credentials.
queryDB( query, conn_name = "default", db_type = NULL, username = NULL, password = NULL, host = NULL, port = NULL, database = NULL, warehouse = NULL, account = NULL, role = NULL, sslmode = NULL, timeout = 15 )
queryDB( query, conn_name = "default", db_type = NULL, username = NULL, password = NULL, host = NULL, port = NULL, database = NULL, warehouse = NULL, account = NULL, role = NULL, sslmode = NULL, timeout = 15 )
query |
A string of the SQL query to execute |
conn_name |
The name of the connection to use in snowquery_creds.yaml (e.g. "my_snowflake_dwh") |
db_type |
The type of database to connect to (e.g. "snowflake", "redshift" or "postgres") |
username |
The username to use for authentication |
password |
The password to use for authentication |
host |
The hostname or IP address of the database server |
port |
The port number to use for the database connection |
database |
The name of the database to connect to |
warehouse |
Snowflake The name of the warehouse to use for the Snowflake connection |
account |
Snowflake The name of the Snowflake account to connect to |
role |
Snowflake The name of the role to use for the Snowflake connection |
sslmode |
Whether to use sslmode for the postgres or redshift connection |
timeout |
The number of seconds to wait for the database to connect successfully |
A data frame containing the results of the query
## Not run: # Query the database and get a dataframe of results result <- queryDB("SELECT * FROM my_table", conn_name='my_snowflake_dwh') print(result) ## End(Not run) ## Not run: # You can also pass in credentials manually result <- queryDB("SELECT * FROM my_table", db_type='snowflake', username='my_username', password='my_password', account='my_account', database='my_database', warehouse='my_warehouse', role='my_role', timeout=30) print(result) ## End(Not run)
## Not run: # Query the database and get a dataframe of results result <- queryDB("SELECT * FROM my_table", conn_name='my_snowflake_dwh') print(result) ## End(Not run) ## Not run: # You can also pass in credentials manually result <- queryDB("SELECT * FROM my_table", db_type='snowflake', username='my_username', password='my_password', account='my_account', database='my_database', warehouse='my_warehouse', role='my_role', timeout=30) print(result) ## End(Not run)