Title: | Query 'Snowflake' Databases with 'SQL' |
Version: | 1.2.1 |
Maintainer: | Dani Mermelstein <dmermelstein@hey.com> |
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. |
URL: | https://github.com/mermelstein/snowquery |
BugReports: | https://github.com/mermelstein/snowquery/issues |
Imports: | reticulate, yaml, DBI, RPostgres, RSQLite |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.1 |
License: | GPL (≥ 3) |
NeedsCompilation: | no |
Packaged: | 2024-10-02 18:55:58 UTC; dani |
Author: | Dani Mermelstein [aut, cre, cph] |
Repository: | CRAN |
Date/Publication: | 2024-10-02 20:00:02 UTC |
snowquery: 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.
Author(s)
Maintainer: Dani Mermelstein dmermelstein@hey.com [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/mermelstein/snowquery/issues
Query a database
Description
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.
Usage
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
)
Arguments
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 |
Value
A data frame containing the results of the query
Examples
## 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)