Use $column in the sql string and pass the column as a character string. The [...] is in case the column name has a dot in it which is accepted by R but must be escaped to use it in SQL.
(Despite the fact that tidyverse does it it is generally not a good idea to use nonstandard evaluation and using it will make your software harder to write and to use. That means we should pass "x" instead of x. A key advantage is that then it becomes easy to store the variable name itself in a variable, as opposed to hard coding it, which may be desirable when writing functions which should be general.)
library(sqldf)
test2 <- function (db, column) {
fn$sqldf("SELECT [$column] FROM db")
}
DB1 <- data.frame(x = c(1, 2, 3))
test2(DB1, "x")
## x
## 1 1
## 2 2
## 3 3
If you did want to use NSE anyways, despite my warning, then it would be like this.
library(sqldf)
test3 <- function (db, column) {
column <- deparse(substitute(column))
fn$sqldf("SELECT [$column] FROM db")
}
DB1 <- data.frame(x = c(1, 2, 3))
test3(DB1, x)
## x
## 1 1
## 2 2
## 3 3