Pyodbc Issue with Teradata - linux

Getting below error while connecting with Teradata from pyodbc in Linux
('632', '[632] 523 630 (0) (SQLDriverConnect)')
Details below:
Connection String
DRIVER={Teradata};DBCNAME=;UID=;PWD=;QUIETMODE=YES;
Pyodbc Version:pyodbc-2.1.8
Python Version: 2.7.3
Teradata below:
RELEASE 14.10.03.07
VERSION 14.10.03.06
Linux Host Details: 2.6.39-400.17.2.el5uek
Please help.

Need to export ODBCINI path, its done
export ODBCINI=/opt/teradata/client/14.10/odbc_64/odbc.ini

Related

Can I see the connection string in DBeaver and copy it to make a connection to DB2 in Python? [duplicate]

I have a running DBeaver connection to a DB2 database and now I would like to connect also in Python with the DB2 database securely over SSL. As authenticating I would like to use my windows account instead of giving a PW and UserID, to do so in DBeaver I changed:
javax.net.ssl.keyStoreType = Windows-ROOT
javax.net.ssl.trustStoreType = Windows-MY
Is this also possible with the Python connection?
I tried the following to set up the connection:
import ibm_db
connID = ibm_db.connect('DRIVER={IBM DB2 ODBC DRIVER};'
'DATABASE=XXXX;'
'HOSTNAME=XXXXYYY.net;'
'PORT=9797;'
'PROTOCOL=TCPIP;'
'SECURITY=ssl;'
'SSLSERVERCERTIFICATE=C:/Users/..../cert.cer;'
, '', '')
if connID is None:
print("\nERROR: Unable to connect.")
exit(-1)
print("Connected!")
I get the following error:
SQLCODE=-30082][CLI Driver] SQL30082N Security processing failed with reason "17" ("UNSUPPORTED FUNCTION"). SQLSTATE=08001
Some details:
M:\>"C:\Users\.conda\pkgs\ibm_db-3.0.1-py37hfa6e2cd_1\Lib\site-packages\clidriver\bin\db2level.exe"
DB21085I This instance or install (instance name, where applicable: "*") uses
"64" bits and DB2 code release "SQL11013" with level identifier "0204010F".
Informational tokens are "DB2 v11.1.3031.295", "s1804271300",
"DYN1804271300WIN64", and Fix Pack "3a".
Product is installed at
"C:\Users\.conda\pkgs\ibm_db-3.0.1-py37hfa6e2cd_1\Lib\site-packages\cli
driver" with DB2 Copy Name "IBM Data Server Driver For ODBC and CLI".
I'm using:
Python version 2.7.17
Ibm_db version 3.0.1

Not readable outputs while running pyodbc hive connection with Python 3.7.0 and pyodbc-4.0.28

I am running some code in python using pyodbc by making a connection with Hive. Whenever; I get any error on the console, it is not understandable. Following is an output :
conn=pyodbc.connect("DSN=hive_db", autocommit=True)
pyodbc.InterfaceError: ('28000', '[28000] 䡛牯潴睮牯獫孝桔楲瑦硅整獮潩嵮⠠⤲䔠牲牯漠捣牵摥搠牵湩\u2067畡桴湥楴慣楴湯.ᙸƛ\x00\x00騀샹翾\x00\x02\x00罙\x00鴠샹翾\x00ᙸƛ\x00\x00궈磐罙\x00鞰蒀罙\x00궈磐罙\x00馠샹翾 (2) (SQLDriverConnect)
What can be the possible reason for such an output? How can we convert it to have a readable output?
Thanks,

Rattle 5.1 ODBC connection issue

I've tried the ODBC connection in Rattle 5.1 many times with the same error.
Error in sqlTables(crs$odbc) :
first argument is not an open RODBC channel
In addition: Warning messages:
1: In RODBC::odbcDriverConnect("DSN=ORCL", believeNRows = TRUE) :
[RODBC] ERROR: state 28000, code 1005, message [Oracle][ODBC][Ora]ORA-01005: null password given; logon denied
2: In RODBC::odbcDriverConnect("DSN=ORCL", believeNRows = TRUE) :
ODBC connection failed
I've even hard-coded the password in OCBC.ini but it still doesn't work.
RODM_open_dbms_connection with the same DSN works fine.
I figured this out. I downloaded R 3.4.3 on another laptop and the ODBC connection works. It's R 3.5.0 that it has problem with. Looks like Rattle 5.1.0 may not be compatible with R 3.5.0 yet.

How to connect select data from Informix database in python3 using pyodbc / unixODBC

I'm having a problem selecting data from Informix database tables using python3.5 and pyodbc/unixODBC.
I have a little py file (ifx.py) the contents of which are:
import pyodbc
db=pyodbc.connect('DSN=Test1')
db.execute("SELECT * FROM customer ")
and I get an error :
pyodbc.Error: ('HY000', '[HY000] [Informix][Informix ODBC Driver]Invalid byte in codeset conversion input. (21000) (SQLExecDirectW)')
All the searches I've done imply something to do with LOCALE settings, but I check and they're all set the same:
CLIENT_LOCALE=en_US.819
DB_LOCALE=en_US.819
dbs_collate=en_US.819
If I use the unixODBC 'isql' utility I can connect to and query the data happily.
Version Information.
unixODBC.x86_64 0:2.2.14-14.el6
pyodbc.version => '4.0.6'
Linux => Red Hat Enterprise Linux Server release 6.8
python3.5 => Python 3.5.3
Database => IBM Informix Dynamic Server Version 12.10.FC6X5
ClientSDK => IBM Informix CSDK Version 4.10, IBM Informix-ESQL Version 4.10.FC6
Environment Variable ODBCINI points to /etc/odbc.ini. Contents are:
[ODBC Data Sources]
Test1=IBM INFORMIX ODBC DRIVER
;
; Define ODBC Database Driver's Below - Driver Configuration Section
;
[Test1]
Driver=/opt/informix/lib/cli/iclis09b.so
Description=IBM INFORMIX ODBC DRIVER
Database=eunice
LogonID=
pwd=
Servername=indika_test
Port=9916
CursorBehavior=0
CLIENT_LOCALE=en_US.819
DB_LOCALE=en_US.819
TRANSLATIONDLL=/opt/informix/lib/esql/igo4a304.so
/etc/odbcinst.ini contents:
[ODBC Drivers]
IBM INFORMIX ODBC DRIVER=Installed
[IBM INFORMIX ODBC DRIVER]
Driver=/opt/informix/lib/cli/iclit09b.so
Setup=/opt/informix/lib/cli/iclit09b.so
APILevel=1
ConnectFunctions=YYY
DriverODBCVer=03.51
FileUsage=0
SQLLevel=1
smProcessPerConnect=Y
and odbcinst -j output is
unixODBC 2.2.14
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /etc/odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Thanks in advance for any help or suggestions.
This is probably due to an multibyte character in the customer table, which can not be converted to Latin 1, ISO 8859-1 from UTF8. Even with same codes set on both CLIENT_LOCALE and DB_LOCALE, an ODBC client makes an internal conversion from UTF-8 to 8859. If there are any 2-byte chars (chars beyond extended-ascii 255) they will not convert to a Latin-1 client. I would look at the data in customer table and identify the problematic data.
It is possible (or likely) that there is an Unicode encoding mismatch.
On my Debian system, the python builds (both 2.7 and 3.4) use UCS-4 encoding. You can verify with this command:
python3 -c "import sys;print(sys.maxunicode<66000 and'UCS2'or'UCS4')"
Once you find the encoding, you need to make sure the Informix odbc.ini file has the same Unicode encoding. In my odbc.ini file,
[ODBC]
;uncomment the below line for UNICODE connection
UNICODE=UCS-4
I hope this resolves your issue.
Thanks for the responses. It was unicode mismatch.
db=pyodbc.connect('DSN=Test1')
db.setdecoding(pyodbc.SQL_WCHAR, encoding='UTF-8')
db.setdecoding(pyodbc.SQL_CHAR, encoding='UTF-8')
db.setencoding(encoding='UTF-8')
By adding setencoding and setdecoding I was able to successfully select data form the Informix DB.

Need Help for connecting MSSQL SERVER From Linux(ubuntu)

I just installed the ODBC driver in the Ubuntu, but still I am facing issues while connecting the database from Perl. Here is the description on what I have done in my machine.
I installed the MSSQL Driver and Unix ODBC from easysoft website. The path details in my machine follows:
ODBC Installed Path:- user/local/easysoft/unixodbc
Data Source and Driver path: user/local/etc Sample Code:
#!/usr/bin/perl
use strict;
use DBI;
my $dsn="DBI:ODBC:DRIVER={SQL Server};Server=xxx.xxx.xxx.xxx,1433;database=DB_name";
my $dbh = DBI->connect($dsn, "username", "password" ,{AutoCommit => 1} )
or die DBI::errstr;
Error:
DBI connect('DRIVER={SQL Server};Server=xxx.xxx.xxx.xxx,1433;database=DB_name','username',...) failed: unixODBCDriver Manager Can't open lib 'SQL Server' : file not found (SQL-01000) at sample.pl line 5
unixODBCDriver ManagerCan't open lib 'SQL Server' : file not found (SQL-01000) at sample.pl line 5.
DRIVER={SQL Server}
You code is attepmting to connect to a [SQL Server] driver in your odbcinst.ini file. However if you are using the Easysoft ODBC-SQL Server Driver you will need to use :-
Driver={Easysoft ODBC-SQL Server}

Resources