How to import SQL read only database

Hello,

I'm trying to connect to a SQL server database from R. The database is read only, will I still be able to do that? I have tried the following code, but it's not working for some reason.

dbconnection <- dbConnect(odbc(),
                                  Driver="SQL Server",
                                  Server="",
                                  Database="",
                                  uid="",
                                  Pwd="",
                                  Trusted_Connection="yes",
                          Authentification="SQL Server Authentification")

Thank you :slight_smile:

Hello,

it is perfectly normal to connect to databases with only read access. In fact you probably do not wish for a write access to a production dabatase; knowing you can not break anything come what may is kind of liberating :slight_smile:

The approach you are taking is in princple a correct one, but you do not give us enough information to help. What error message do you get? Have you loaded all libraries required? dbConnect is from {DBI} and odbc from {odbc}.

1 Like

If you are on Windows, you could define a DSN in your ODBC-Source-Settings (e.g.: https://docs.microsoft.com/en-us/sql/integration-services/import-export-data/connect-to-an-odbc-data-source-sql-server-import-and-export-wizard?view=sql-server-2017) and then connect with:

dbConnect(odbc(),
                    dsn      = "DSN_NAME",
                    database = "DATABASE_NAME",
                    encoding = "",
                    ...)
``

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.