0

I am attempting to write a containerized Node application that intakes Microsoft Access databases and accesses the data within. I want to put the application in a docker container and wish to use npm odbc to interact with Access. I don't have much experience creating containers so much of this has been a learning process.

I am struggling to get odbc installed and configured for Access. Per the documentation that I linked, there are three requirements for odbc.

  1. Install unixODBC and unixODBC-devel
  2. Install ODBC drivers for target database
  3. Define odbc.ini and odbcinst.ini

I am struggling to get any amount of odbc functionality working, so I assume the issue is that I'm not configuring the environment correctly. Here is my base Dockerfile where I define the container environment. Running the AccessDatabaseEngine.exe file returns a Not Found error, even though I'm pretty sure that the file should exist there. For now, I have commented out the line. The application code runs from a different set of Dockerfiles that build off this one.

# Use Ubuntu OS as base image
FROM ubuntu:latest

# Set env vars
ENV NPM_CONFIG_LOGLEVEL info

# odbc requirement #1
# Install unixODBC, unixODBC-devel, and curl
RUN apt-get update
RUN apt-get -y install unixodbc
RUN apt-get -y install unixodbc-dev
RUN apt-get -y install curl

# Download & install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_12.x | bash
RUN apt-get -y install nodejs

# odbc requirement #2
# Install ODBC drivers for Access database
RUN curl -LJO https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe
RUN cp AccessDatabaseEngine.exe /bin/
RUN chmod +x /bin/AccessDatabaseEngine.exe
# RUN ['/bin/AccessDatabaseEngine.exe'] # Error: #14 0.249 /bin/sh: 1 [/bin/AccessDatabaseEngine.exe]: not found

# Run node
CMD [ "node" ]

In my application, I attempt to use odbc like this. The connection string for odbc requirement #3 was found here:

// Test function to test out npm odbc
exports.export = async (file) => {
    // odbc requirement #3
    // Make Access connection
    const conn = await odbc.connect(`Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=${file.path}`);

    // Execute test query
    const res = await conn.query('SELECT 1');
    console.log(JSON.stringify(res));
}

I feel pretty good about my implementation of odbc requirements #1 and #3, but I am struggling with #2 (Install ODBC drivers for target database). Not only am I struggling to run the AccessDatabaseEngine.exe, but I'm also not 100% sure that it's even the correct file to be trying to install. I ran into this and that seems like it might the odbc driver that I need. However, I tried dockerizing the code they gave and ran into more issues.

Again, I want to create a containerized Node application that uses the ODBC npm library to access the data within a Microsoft Access database. Does anybody have any experience doing this? Any help would be appreciated. Thanks ahead of time.

Mike H
  • 35
  • 7
  • Eh... You're trying to install an exe on Linux? Good luck with that – Erik A Jun 24 '21 at 18:35
  • @ErikA Good catch. Seems obvious now. I don't think I'm using the right file for the odbc driver. I'll likely post an update following the documentation from [this](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#ubuntu17). – Mike H Jun 24 '21 at 20:40
  • Eh, that's a driver for SQL server, an entirely different product than Access. There's no first-party ODBC driver for Access on Linux. There are some third-party ones (eg mdbtools) that offer limited functionality, but I wouldn't bet on it working well. If you want to use Access, you need Windows or things get messy, so if you don't have an extraordinarily good reason to use Access I'd try another database system – Erik A Jun 24 '21 at 20:45
  • @ErikA You're right, that isn't for Access. I'm grasping at the wrong straws here. The original exe file that I had was the right file. I re-read the system requirements and it requires a Windows OS. Can't happen on Linux, no way around it it seems. Using Access is non-negotiable. Unless somebody recommends an alternative it seems that my app will have to be built on a Windows OS, not Linux. Thank you for the insight! I needed a fresh perspective. – Mike H Jun 25 '21 at 01:18

1 Answers1

0

As it was said in the comments. I'm grasping at the wrong straws here. I cannot download Access Drivers onto my Linux machine. Per the driver system requirements here, I must use a Windows OS.

Mike H
  • 35
  • 7
  • 1
    Thre's a Linux MS-Access ODBC diver from easysoft, but it's commercial. See here; https://www.easysoft.com/products/data_access/odbc-access-driver/index.html#section=tab-3 – Alex_M Jul 26 '21 at 21:12
  • @Alex_M Good to know, but I'm probably going to go a different direction. I feel like I'd be asking for issues further down the road. Thanks for the comment. – Mike H Jul 29 '21 at 01:06