node-odbc
node-odbc copied to clipboard
[HELP] Error when calling the 'connectToDatabase'
I am getting the following error when calling the 'connectToDatabase' method in the 'node-odb' package:
[Error: [odbc] Error connecting to the database] {
odbcErrors: [
{
state: '01000',
code: 0,
message: "[unixODBC][Driver Manager]Can't open lib 'Amazon Redshift (x64)' : file not found"
}
]
}
I'm guessing this means that 'node-odbc' cannot find my 'odbc.ini' and 'odbcinst.ini' files, or that it cannot find the Redshift odbc driver.
I am struggling a bit to understand what I am doing wrong. I tried to follow the ODBC connection setup instructions here closely: https://docs.aws.amazon.com/redshift/latest/mgmt/configure-odbc-connection.html#odbc-driver-sysreq-linux
I am using this Docker image: public.ecr.aws/docker/library/node:16.20.0-bullseye
My Redshift drivers are in the default location: /opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so
I've copied my 'odbc.ini' and 'odbcinst.ini' files to one of the suggested locations: /etc/.odbc.ini /etc/.odbcinst.ini /etc/.amazon.redshiftodbc.ini
I've tried a few other locations as well, but I get the same error no matter what.
I understand glibc is a prereq for the setup. My image comes with libc-2.31 (not sure if that is an acceptable equivalent).
Here is my client code:
const { connect } = require("odbc");
async function connectToDatabase() {
// connection configuration object
const connectionConfig = {
connectionString:
"Driver={Amazon Redshift (x64)}; Server=prod-cda-aws-euc1-vpc004-cdwh-rshft-pecrm.cihsil4oz9dt.eu-central-1.redshift.amazonaws.com; Database=csl_service_now_com",
connectionTimeout: 10,
loginTimeout: 10,
};
const connection = await connect(connectionConfig);
}
I feel like I am close, but have some minor detail off. Have you ever come across any similar setup issues? Appreciate any advice.
Hi, did you try renaming the odbc.ini and odbcinst.ini in the /etc folder without the period in front?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.