Search code examples
macosazure-sql-databaserodbc

Upload .csv to AzureSQL using terminal


I have a .csv that my R code updates daily. I want this .csv to be present in the azureSQL, thus I want to write a script which does this

I tired to do the same using R (ODBC) but this was too slow. I thought of using terminal for this because R can also do this using system().

I know something called BCP, but I can't figure out how to do this in Mac despite this link (http://blog.nguyenvq.com/blog/2010/04/15/accessing-ms-sql-server-from-command-line-in-mac-os-x-and-linuxunix/)

P.S: I have ODBC link from the Azure SQL


Solution

  • Here are follow-up posts to the one you pointed above which should help you connect from your Mac: http://blog.nguyenvq.com/blog/2010/05/16/freetds-unixodbc-rodbc-r/ http://blog.nguyenvq.com/blog/2013/04/06/guide-to-accessing-ms-sql-server-and-mysql-server-on-mac-os-x/

    library(RODBC)
    
    ch1 <- odbcConnect(dsn="sqlserver01", uid="username", pwd="password")<br>
    odbcQuery(ch1, "select name from master..sysdatabases") <br>
    odbcFetchRows(ch1)
    

    That said, if you could also please share your script I could help figure out why it is running slowly.