Parameterized queries with RODBC

后端 未结 1 1511
终归单人心
终归单人心 2020-11-27 20:55

I have a variable in R that I would like to pass to a database. I could use paste like many suggest when reading Google results, but that is unsafe bec

相关标签:
1条回答
  • 2020-11-27 21:55

    Mateusz Zoltak wrote RODBCext package in 2014 (based on work by Brian Ripley and Michael Lapsley):

    conn = odbcConnect('MyDataSource')
    
    sqlPrepare(conn, "SELECT * FROM myTable WHERE column = ?")
    sqlExecute(conn, 'myValue')
    sqlFetchMore(conn)
    

    Source: http://cran.r-project.org/web/packages/RODBCext/vignettes/Parameterized_SQL_queries.html

    0 讨论(0)
提交回复
热议问题