Chapter 3 Operating System
This chapter covers the basics of an opinionated operating system (OS) configuration and package management.
3.1 Package Management
Homebrew can be installed using the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
If you are using a Windows machine, you have two options. You can use Homebrew through the Windows Subsystem for Linux, or you can go with Chocolatey which relies on the native Windows shell. If using WSL, you may need to enter BIOS and enable CPU virtualization.
3.2 ODBC
ODBC stands for Open Database Connectivity.
The preferred method of installing ODBC and the appropriate drivers is through your operating system package manager (i.e. Homebrew or Chocolatey). This is as simple as {bash, eval=FALSE} brew install psqlodbc
on Mac/Linux, or {bash, eval=FALSE} choco install psqlodbc
on Windows.
Alternatively, a flat package install of the Postgres ODBC driver can be downloaded here. Make sure you follow the README to select the correct installation package, and that you install the latest version.
Be sure to check your odbcinst.ini
file for a path to the correct ODBC driver. Usually the name of this file will be similar to psqlodbcw.so
. If you installed ODBC and the PostgreSQL ODBC Driver through Homebrew you can run the command odbcinst -j
in your OS terminal to locate the odbcinst.ini
file. Look at the DRIVERS
line. To find the location of the driver you can use find / -name "*.so | grep "psql"
. Make sure the file you lik to ends with a w
before the file extension, not an a
.
If you have the choice (normally on Windows), use the Unicode version of the driver rather than the ANSI version.
Once configured correctly, you can run odbc::odbcListDrivers()
in R. If no record for PostgreSQL shows up, your configuration needs more work. Reach out if you need assistance.
Resources: - https://hiltmon.com/blog/2013/09/18/setup-odbc-for-r-on-os-x/ - https://stackoverflow.com/questions/52316708/r-and-rstudio-not-detecting-installed-postgresql-or-any-other-odbc-drivers