ODBC Issue
The database reported an error: [unixODBC][Driver Manager]Data Source name not found, and no default driver specified
As shown as below, QT application trying to connect a database file of type DBF (.dbf), when we try to execute the application we got the above error.
QSqlDatabase db;
db = QSqlDatabase::addDatabase("QODBC");
QString str("DRIVER={Microsoft dBase Driver (*.dbf)}; DBQ=/path/to/dbf/files");
db.setDatabaseName(str);
if(db.open())
{
...
}
else
{
...// Failure
}
Referred the link (https://www.easysoft.com/support/kb/kb01039.html) and followed the below steps:
The configuration files odbc.ini and odbcinst.ini are present with the appropriate content.
Exported the variables ODBCSYSINI, ODBCINSTINI and ODBCINI with /etc/odbc.ini, /etc/odbcinst.ini and /home/user/.odbc.ini
From the same shell where we have exported the variables, tried to execute the application however encountered with the error "The database reported an error: [unixODBC][Driver Manager]Data Source name not found, and no default driver specified
Please find the content of the odbc.ini and odbcinst.ini
odbc.ini file:
[ODBC Data Sources]
TestODBC=MyODBCDriver
[TestODBC]
Driver=path/to/driver file
DataDirectory=path/to/where my dbf files resides
[Default]
Driver=path/to/driverfile
DataDirectory=path/to/where my dbf files resides
odbcinst.ini file:
[ODBC Drivers]
MyODBCDRIVER=Installed
[MyODBCDriver]
Description=ODBC Driver
Driver=/path/to Driver file
[ODBC]
Trace = Yes
Please provide any suggestion or solution to resolve the issue
Related
I am trying to establish a connection to an Oracle Database in RStudio (Version 2022.07.1 Build 554. Running on SUSE SLE15, SP4).
The connection should by established via an ldap-Server. Its address is in my ldap.ora file which is in /opt/instantclient_19/network/admin.
The code isql my_datasource does establish the connection.
Putting the following code in an R-file an executing via Rscript establishes the connection.
dbConnect(
odbc::odbc(),
dsn = "my_datasource",
UID = "***",
PWD = "***"
)
Trying to source the same script in RStudio (or RStudio Server) throws an error:
Error: nanodbc/nanodbc.cpp:1021: 00000: [Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified
There should be a .Renviron file in your home directory. If not, you'll want to create a text file and save it with .Renviron as the filename. In that file, you'll want to define a path for the ODBCINI environmental variable to an ".odbc.ini" or "odbc.ini" file. For example,
ODBCINI = ~/.odbc.ini
The file in this path should list all DSNs you can use to make a connection. For more information, please see https://solutions.rstudio.com/db/best-practices/drivers/.
Reading documentation here.
I would like to use an odbc connection with Snowflake. I'm already able to get this working by adding .odbc.ini to my home directory with a configuration that looks similar to this:
[snowflake]
Description=SnowflakeDB
Driver=SnowflakeDSIIDriver
Locale=en-US
SERVER=ourco.us-east-1.snowflakecomputing.com
PORT=443
SSL=on
ACCOUNT=ourco.us-east-1
UID=MY_NAME
PWD=$MyPassword
This works. With this config, I'm able to create a connection and query our database.
However I would like to use odbc with keys instead of my password. Followed guide here on creating keys and added them within SF interface.
I then updated my odbc.ini file:
[snowflake]
Description=SnowflakeDB
Driver=SnowflakeDSIIDriver
Locale=en-US
SERVER=ourco.us-east-1.snowflakecomputing.com
PORT=443
SSL=on
UID=MY_NAME
ACCOUNT=ourco.us-east-1
PRIV_KEY_FILE=/home/rstudio-blah/keys/rsa_key.p8 # this is where I stored the key
SNOWSQL_PRIVATE_KEY_PASSPHRASE=potatoes{ # not my real pwd
When attempting to connect with this set up I got error message:
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Snowflake][DSI] (20032) Required setting 'PWD' is not present in the connection settings.
I tried adding PWD= just trying to trick it with a null value but then got:
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Snowflake][Snowflake] (31)
Password not found.
I then tried adding AUTHENTICATOR=SNOWFLAKE_JWT which gave error:
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Snowflake][Snowflake] (44)
Error finalize setting: Marshaling private key failed.
How can I connect via odbc using a key value pair as opposed to a PWD?
I'm trying to create a connection between R (3.3.3) Using RStudio (1.0.143) and Filemaker Pro Advanced 15 (15.0.3.305). I'm trying to create the connection using RODBC (1.3-15).
So far I:
Created a toy FM Pro database for testing
User id: Admin
Password: password
Followed these instructions for creating a DSN
Created a DSN for my toy FM Pro database called test_r
Successfully tested the connection to test_r
Unsuccessfully attempted to connect to the DSN in RStudio in the following two ways:
fm_connection <- odbcConnect(dsn="test_r", uid="Admin", pwd="password")
Which returns the following error:
[RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specifiedODBC connection failed
AND
constr <- paste("driver={FileMaker ODBC}",
"server=127.0.0.1",
"database=test_r",
"uid=Admin",
"pwd=password",
sep=";")
fm_connection <- odbcDriverConnect(constr)
Which returns the following error:
[RODBC] ERROR: state 01000, code 0, message [unixODBC][Driver Manager]Can't open lib 'FileMaker ODBC' : file not foundODBC connection failed
However, you can see that the driver is there:
Finally, I've unsuccessfully tried using these (and other) references to resolve this issue:
https://cran.r-project.org/web/packages/RODBC/vignettes/RODBC.pdf
https://community.filemaker.com/thread/165849
Nothing seems to work so far. I'm not tied to RODBC, but I do need a solution that works for Mac OS. Any help is appreciated!
Here are some imortant troubleshooting steps for MacOS. I've had the same error in R and therefore I think there's a good chance that this your issue. The setup of ODBC can be rather complicated since several software components with multiple versions are involved. You've already verified that ODBC sharing is on in this particular FileMaker database.
Verify your installation of unixodbc:
ODBC Manager is actually optional. It manages the ini files described below. But after installing unixodbc, you can also edit these ini files in a text editor without ODBC Manager.
To install Homebrew, execute this command.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then, install unixodbc. This provides for ODBC connectivity at the system level.
brew update
brew install unixodbc
Verify the driver:
The driver should be installed here:
/Library/ODBC/FileMaker\ ODBC.bundle/Contents/MacOS
That folder will contain these two files:
SetupToolTemplate fmodbc.so
Here's the full driver path:
/Library/ODBC/FileMaker\ ODBC.bundle/Contents/MacOS/fmodbc.so
Verify the config files:
The folder
/Library/ODBC
should contain these files:
FileMaker ODBC.bundle odbc.ini odbcinst.ini
Additionally, the unixodbc should contain only the latest version. If you have an earlier version, delete it. Now, only 2.3.4 is present.
/usr/local/Cellar/unixodbc/2.3.4
also contains
odbc.ini odbcinst.ini
Mirror the odbc.ini and odbcinst.ini files:
As described above, there are two copies of each of these files in two different locations. Make sure that the contents of both are equal. That means both copies of odbcinst.ini will define the drivers. And both copies of odbc.ini will contain the connections. Maybe this isn't 100% necessary, but it's what I needed to do.
Test with isql:
B:etc bobby$ isql -v DSNname admin password
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
If you still have any issues after completing these steps, please share additional details so that I can update the answer.
I got this to work using odbc instead of RODBC some new R code:
con <- DBI::dbConnect(odbc::odbc(),
driver = "/Library/ODBC/FileMaker ODBC.bundle/Contents/MacOS/FileMaker ODBC",
server = "127.0.0.1",
database = "/Users/bradcannell/Dropbox/Filemaker Pro/Notes/test_r.fmp12",
uid = "Admin",
pwd = "password")
I do not have the permission to edit the system-wide odbc.ini file, therefore I am searching for alternative ways to specify connection parameters towards Vertica.
I have unpacked the needed libraries to a certain location, and am attempting to create a connection string from my "custom" config file.
Is it possible to explicitly specify the path to the driver (and any other necessary parameters) when using pyodbc.connect?
Example intention (fails with the error below):
conn = pyodbc.connect("DRIVER=path/to/libverticaodbc.so;...")
Error:
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')
Alternatively, is there another option to use odbc.ini files other than the ones at /etc/, e.g. through setting an environment variable?
I recommend to avoid the use of ODBC driver to connect to Vertica .
Vertica release native driver for python , see attach full details and examples :
https://github.com/uber/vertica-python
I hope you will find it us-full
Thanks
You can put a file called .odbc.ini in your home directory which will be for user specific ODBC settings.
http://www.unixodbc.org/odbcinst.html
I'm trying to set up dsn with qt and i cant get it to work. The dsn does work with isql.
I'm using ubuntu 12.04
POSTGRES is the dsn.
connection line:
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("localhost");
db.setDatabaseName("POSTGRES");
error:
FATAL: database "POSTGRES" does not exist.
I don't understand why qt doesn't do the look up to find the database behind. i made symlink (usr/local/etc) to odbc.ini and have odbcinst.ini aswell sqli does work with POSTGRES dsn.
Perhaps where will qt look for these files? Googled for 3 days now without success
I kind of gave up cant solve this thank you for any help.
I believe your problem is that you're using the wrong driver. According to the Qt documentation, you need to be using the ODBC driver for DSN files to work - for example:
db = QSqlDatabase::addDatabase("QODBC");
Also note that, again according to the Qt documentation, if you're trying to pass a DSN filename to setDatabaseName, then it MUST have a ".dsn" file extension:
For the QODBC driver, the name can either be a DSN, a DSN filename (in which case the file must have a .dsn extension), or a connection string.
And, finally, it must be listed in your odbc.ini.