How to create ODBC "DSN" for cross-platform testing? - windows

I need a simple ODBC test scenario on WIN which I can configure very simply and be assured it is working in support of another question at Unix.SE.
In a nutshell I'm trying to setup a PyODBC/Python script connection from Debian 10 (192.168.1.2) to Windows 10 in KVM/QEMU virtual system (192.168.1.12).
First, on the Windows 10/KVM, I see the ODBC Data Source Administrator has a tab File DSN and Microsoft Text Driver. Can I use FileDSN to test Python PyODBC connection to ODBC using a simple CSV file in place of Server?? (My research with ODBC only finds running server instances).
Next, what I tried:
On Debian I installed ODBC Microsoft driver for Linux.
Shutdown the Windows 10 firewall, and I can ping in both directions:
$nmap -p 22 192.168.1.12 # Deb to Win
> Test-NetConnection 192.168.1.2 -p 22 # Win to Deb
On Windows 10/KVM I added a FileDSN with Microsoft Text Driver. I created a CSV file (odbc_test_01.csv) with simple header and one row of data (IE. {'ID' : 1, 'NAME' : 'FOO'})
Created a Jupyter Notebook to make testing easier. Here is my connection string and the results:
cn = pyodbc.connect(r'Driver={ODBC Driver 17 for SQL Server};' # Driver installed above
r'FILEDSN=odbc_test_01.csv;' # my attempt at FileDSN
r'SERVER=192.168.1.12;' # KVM IP tested with ping
r'Trusted_Connection=no;' # explicit; use UID/PWD
r'UID=<username>;' # Windows user name
r'PWD=<password>', # Windows user password
autocommit=True)
OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
Tried isql from Debian command line with same string:
isql -v -k ''Driver={ODBC Driver 17 for SQL Server};FILEDSN=odbc_test_01.csv;SERVER=192.168.1.12; Trusted_Connection=no;UID=<username>;PWD=<password>'
Similar pages here at SO:
Authenticate from Linux to Windows SQL Server with pyodbc
Python pyodbc connect to Sql Server using SQL Server Authentication

An ODBC "File DSN" is not a driver for accessing data in a file. It is a way to specify a DSN (connection information for a target database) as values in a standalone file instead of in a standard configuration file on Linux (e.g., /etc/odbc.ini) or in the Windows registry.
If you need to "clone" a Windows DSN entry for use in a Linux environment then you may find my dump_dsn utility helpful. It retrieves an ODBC DSN from the Windows registry and presents it in a form that you could use to recreate the DSN on Linux.
For example, say I had a DSN named "mssql199" on Windows and when I ran dump_dsn.to_text("mssql199") on it I got
[mssql199]
Driver=ODBC Driver 17 for SQL Server
Description=with UseFMTONLY
Server=192.168.0.199
Database=myDb
Encrypt=No
TrustServerCertificate=No
ClientCertificate=
KeystoreAuthentication=
KeystorePrincipalId=
KeystoreSecret=
KeystoreLocation=
UseFMTONLY=Yes
Trusted_Connection=No
To use that same DSN on a Linux box I would have to
copy that block into /etc/odbc.ini (or equivalent, for a "System DSN") or ~/.odbc.ini (for a "User DSN") to use DSN=mssql199, or
save that block with an [ODBC] header instead of [mssql199] to a file, e.g., /home/gord/mssql199_file.dsn (for a "File DSN") and use FILEDSN=/home/gord/mssql199_file.dsn
Edit re: "Can I use FileDSN to test Python PyODBC connection to ODBC using a simple CSV file in place of Server??"
No. An ODBC DSN or FILEDSN on the Windows box will only be useful to connect from the Windows box to a data source (either locally, or on some other machine). We cannot connect from one machine (e.g., Linux) to an ODBC DSN entry on another machine

I created an SQLite database. Then I added SQLite drivers for ODBC.

Related

How to install IBM db2 cli drivers on mac osx mojave

In order to use db2 with node.js on my mac. I have installed the db2 drivers - DB2 v11.1.4.5.
I also configured my environment paths so that the correct config files will be used by unixODBC
I configured the odbcinst.ini, ODBC.ini , db2cli.ini, and the db2dsdriver.cfg files
The issue is that I get the error below when I run the iqsl command or the db2cli validate command
My Error
[S1000][unixODBC][IBM][CLI Driver] SQL10007N Message "0" could not be retrieved. Reason code: "3".
unixODBC isql command syntax
isql usrProd userid password
db2cli validate command syntax
db2cli validate -dsn alias -connect -user userid -passwd password
Environment path stored in file ~/.bash_profile
export PATH=$PATH:/usr/local/share/odbc_db2/clidriver/bin/
export DB2CLIINIPATH=/usr/local/share/odbc_db2/clidriver/cfg/
export DB2DSDRIVER_CFG_PATH=/usr/local/share/odbc_db2/clidriver/cfg/
I have been documenting the steps that I took to install the db2 command line drivers.
My documentation
locations of the IBM DB2 Drivers I have installed:
Client Version (level/bit): DB2 v11.1.4.5 (special_39510/64-bit)
Client Version (level/bit): DB2 v11.1.1.1 (s1703232000/64-bit)
UPDATE --- 20200413----
I got it to work on my Mac. I did get it to work with Node.js
I contacted a few IBM developers who are working directly on this project, and they gave me access to the proper "IBM i Access ODBC Driver" to connect to the as400 from the mac.
It is being beta tested now. At some point, it should be released. to the general public.
db2cli drivers are not needed, db2cli.ini is not needed:
IBM has specific odbc drivers for the iseries. I dont have permission
to share the drivers with the public, but do know that it will be
possible soon for everyone to connect to db2 installed on the iseries
I got it to work on my Mac and I did get it to work with Node.js
I contacted a few IBM developers who are working directly on this project, and they gave me access to the proper "IBM i Access ODBC Driver" to connect to the as400 from the mac. It is being beta tested now, i assume that at some point, it should be released to the general public.
Note : db2cli drivers are not needed, db2cli.ini is not needed, and setting environment paths are not needed:
IBM has specific odbc drivers for the iseries. I don't have permission
to share the drivers with the public, but do know that it will be
possible soon for everyone to connect to db2 installed on the iseries
For IBM DB2 Warehouse on the IBM CLoud you can go to this url
https://your_tenant.cloud.ibm.com/console/#connection/overview
In above replace your_tenant with your tenant id.

I cannot connect to DSN with Perl Win32:ODBC

Background:
I am using Windows 10 and Perl v5.26.1. I inherited some Perl code that needs to connect to a database. This previously worked using Windows 7 and Perl 5.16.3.
The code is using Win32::ODBC to connect to the database. I get the following error:
Connect failed: [911] [] "[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application"
I am using a 64 bit version of Perl and trying to connect to a 32 bit MS Access database but I am assuming that Win32 is handling this. Also the same setup was working in the Windows 7 setup.
I am able to connect to the database using the ODBC Data Source Administrator.
As an attempt to determine the issue I tried:
use strict;
use Win32::ODBC;
print "DataSources\n";
my (%dsn, $key) = Win32::ODBC::DataSources();
foreach $key (sort keys %dsn) {
print "$key\n";
}
print "Done\n";
This resulted in
DataSources
Done
So I am not finding any DataSources. Running the same code on the Windows 7 machine does generate DataSources.
Running Get-OdbcDsn in Powershell generates a list of data sources.
Question:
Why am I not able to see DataSources using Perl in v5.26.1 using Windows 10?

How to connect to Pervasive SQL server in Ruby Application?

I am trying to connect to a Pervasive Sql Server which is running on Windows machine from my Ruby application which is on Ubuntu Machine. Can Someone please help me on same. Thanks in advance
Below is my configuration on linux machine
/etc/freetds/freetds.conf
[pserver]
host = XXX.XXX.XX.XXX
port = 1583
tds version = 8.0
Under /etc/odbcinst.ini, I have saved the driver info like below
[freetds]
Description=freetds Driver
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
Trace=Yes
TraceFile=/tmp/freetds.log
ForceTrave=Yes
UsageCount=10
fileusage=1
dontdlclose=1
TDS_Version = 8.0
In /etc/odbc.ini, client and database details
[pclient]
Description = Pervasive SQL Server
Driver = freetds
Trace = Yes
Servername = pserver
Port = 1583
Database = "MyDatabasename"
TDS_Version = 8.0
tsql -S pserver -U db_username -P db_password -d MyDatabasename
above cmd gives error saying
Error 20009 (severity 9):
Unable to connect: Adaptive Server is unavailable or does not exist
OS error 111, "Connection refused"
There was a problem connecting to the server
iodbctest ["DSN=pclient;UID=db_username;PWD=db_password"]
this results in
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0812.0326
(iodbctest:6672): Gtk-WARNING **: 20:40:38.693: cannot open display:
Not able to understand the above result and how to handle this. Please help
As far as I know, the only way to access Pervasive PSQL from Ruby would be through ODBC. You need to use the Pervasive Client ODBC driver. Don't use the FreeTDS driver. I've never heard of using the FreeTDS driver to connect to Pervasive PSQL. In fact, this question mentions that FreeTDS doesn't work to Pervasive PSQL. Pervasive PSQL and Microsoft SQL Server are not the same product and the client for one cannot connect to the server of the other.
The short answer would be to install the Pervasive PSQL client on the Ubuntu machine, create the ODBC Datasource name pointing to the database on the Windows machine and then use ODBC from within Ruby to access the data.
You'll want to be on at least Pervasive PSQL v11.30, preferably Actian PSQL v13 (current version as of December 2018). You'll need to download and install the client appropriate for the application. If the Ruby application is 32 bit, you need the 32 bit ODBC driver. If the application is 64 bit, you'll need the 64 bit driver. The 'bitness' of the OS is not as important. You need to use the same PSQL client version as server version. You cannot use the v13 client with a v11 server.

Oracle - Instant Client

I'm trying to install the Oracle Instant Client and ODBC drivers on a 64 bit, Windows 7 machine.
I have downloaded BOTH
Instant Client Package - Basic
Instant Client Package - ODBC
I had put both sets of files in the same directory:
C:\Oracle\instantclient_11_2
I set both the ORACLE_HOME and TNS_ADMIN environment variables to the same directory:
C:\Oracle\instantclient_11_2
Finally, I am trying to execute the "odbc_install.exe" file as an administrator.
ERROR: Oracle ODBC driver with the same name already exists
The one thing I did BEFORE any of this was to install and later uninstall the OracleXEClient.exe file.
Not sure how to proceed???
Open Command Prompt as an Administrator and the run odbc_install.exe from there.
Try odbc_uninstall.exe. Unfortunatelly, entries may remain in Windows registry. You can search (with regedit) for oracle in instant_client_11_2 or simply 11_2 and delete the corresponding entries for the instant client (take care! not all matches 11_2 are for oracle instant client).
After, execute again odbc_install.exe. And additional care if using 32 and 64 bit applications!
You may get this message if you didn't run the command prompt or odbc_install.exe as administrator.

connect to oracle which is hosted on different machine

Hi I am working on a project in which we have oracle DB that is hosted on one machine and java application on other machine. both machines have UNIX OS.i want to develop a shell script that will use DB query and generate a report but i dont have any client(SQLplus) installed on both the machine. so let me know how can i connect to DB and where shud i develop scirpt like on DB unix machine or application machine.
sqlplus -s "/as sysdba
this is use of sql plus i dont have on any machine..
if you have ssh access on both the machines you could run virtually any command(through ssh) you could on the machine itself:
ssh user#server1 "ls ~/"
for example the above will give you a listing of files in "user"s home directory on server1..

Resources