Open worksofliam opened 5 years ago
Tomorrow I will post the blog about using a DSN, which would allow for shorter connection strings like:
const connection = await odbc.connect(`DSN=DEVSERV;Password=password`);
windows-build-tools
has been deprecated. It has be included in node.js. Can we safely skip the step npm i -g windows-build-tools
?
My old IBM Access Client Solutions does not have IBM i Access ODBC Driver
. However, using the old name iSeries Access ODBC Driver
or Client Access ODBC Driver (32-bit)
works well.
This post will explain how to:
node-odbc
on WindowsFor these posts, I will be using Node.js 10.16.0 on Windows.
Building node-odbc
Feeling lazy and don't want to build it manually? Check the bottom of this post for the pre-built binaries for Windows.
Unlike Mac and Linux, the
node-odbc
repository does not provide the runtime binaries for Windows so they have to be built manually. Luckily the tools we need to build it can be installed with just two commands.Windows build tools comes with Python and some Visual Studio Tools (
msbuild
) to compile the C++ from thenode-odbc
repository. Now we can installodbc
and it will build the binary for us automatically to use in our Node.js script.Installing the IBM i ODBC driver for Windows
Feeling lazy or don't have an IBM ID? I am hosting the
IBMiAccess_v1r1_WindowsAP_English.zip
on my website. You can download it here instead.The driver currently requires you to have an IBM ID to download it, it was kind of hard to find it previously but Dawn May created this blog post and Kevin Adler also tweeted this:
Following that short link will give you an IBM ID sign on, which will then show you this page:
You want the third item from the bottom (ACS Windows App Pkg English (64bit)). This will give you a .zip file which you can extract. Inside the zip you can find
Image64a/setup.exe
which you can execute to install the driver:Now, if you open the ODBC Data Source Administrator and head to the Drivers tab you should see the new drivers show up:
A Node.js example
In this example, for the purpose of testing, I am not using a DSN. That will come in the next blog post. Here is my example Node.js script that uses the
odbc
module with Promises.And when we run this script, we get the expected output:
Pre-built
odbc
binaries:To install
odbc
without building it, runnpm i odbc --ignore-scripts
. The contents of the zip file go inside./mode_modules/odbc/build/
.odbc
, Version 2.0.0-4, Windows outdated