Skip to contents

Retrieve a dataset defined by a SQL string

Usage

get_query(sql, db_name = "Elmer")

Arguments

sql

String. The SQL command to send to <db_name>.

db_name

String. The name of the database to run the query against. Should be "Elmer" or "ElmerGeo". Default = "Elmer".

Value

A data frame.

Examples

get_query(sql = "select * from chas.tenure_dim")
#>   tenure_dim_id          created_at          updated_at
#> 1             1 2021-01-08 14:47:29 2021-01-08 15:07:17
#> 2             2 2021-01-08 14:47:29 2021-01-08 15:07:17
#> 3             3 2021-01-08 14:47:29 2021-01-08 15:07:33
#>                     tenure_name tenure_order
#> 1                Owner occupied            1
#> 2               Renter occupied            2
#> 3 Total: Occupied housing units            0
get_query(sql = "select top 10 geoid10 from dbo.TRACT2010", db_name = "ElmerGeo")
#>        geoid10
#> 1  53033022006
#> 2  53033032320
#> 3  53033031703
#> 4  53033031206
#> 5  53033032102
#> 6  53033032210
#> 7  53033032211
#> 8  53033032104
#> 9  53033032313
#> 10 53033032203