How to setup ODBC connection via command line for Teradata driver? - windows-10

I am trying to setup a Teradata ODBC User DSN via below command line code.
%WINDIR%\System32\odbcconf.exe CONFIGDSN "Teradata" "DSN=Test|Description=Test|SERVER=ServerName|Trusted_Connection=Yes|Database=Controltub|UID=<LoginId>"
%WINDIR%\SysWOW64\odbcconf.exe CONFIGDSN "Teradata" "DSN=Test|Description=Test|SERVER=ServerName|Trusted_Connection=Tes|Database=Controltub|UID=<LoginId>"
This code works fine for "SQL Server" driver. However when I try to make changes accordingly for Teradata ODBC creation, it fails without any error.
I get blank in text fields for server name/IP field & user id in ODBC window.

The following worked for me with the Teradata 16.20 Driver on Windows 7:
%WINDIR%\System32\odbcconf.exe CONFIGDSN “Teradata Database ODBC Driver 16.20” “DSN=Test|Description=Test|DBCName={server}|DefaultDatabase=DBC|MechanismName=TD2|Username={user}”
Once you create the DSN, you can go into the Registry under Computer\HKEY_CURRENT_USER\Software\ODBC\ODBC.INI{DSN Name} and try the other property (key) names to customize the DSN creation further. What I provide should get you a basic DSN to connect to Teradata.
Replace TD2 with LDAP if your environment uses LDAP authentication.

Related

Python: Error while connecting to SQL Server (ODBC 17)

Getting below error while executing SQL statement using pd.read_sql()
sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) ('08001',
'[08001] [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL
Provider: [error:0A0C0103:SSL routines::internal error] (-1)
(SQLDriverConnect)')
Python version 3.10.8. Other packages:
pyodbc==4.0.35
pandas==1.5.2
pymysql==1.0.2
sqlalchemy==1.4.46
I want to execute the above command successfully.
The error message 'ODBC 17' distinctively specifies a failure in establishing a connection to a SQL Server database through ODBC driver. This can be caused by;
Incorrect connection details such as server name, database name, username, and password.
ODBC driver not installed or not properly configured on the machine.
In order to solve this, try and verify the connection details and ensure they are correct or Install or reinstall the ODBC driver and make sure it's properly configured.
If the above doesn't work, kindly check the firewall settings and ensure that the connection is not being blocked.
Hope this helps.

Oracle: Why am I getting Error: ORA-00903: invalid table name when database table exists?

Background
I have a NodeJS server powered by ExpressJS that fetches data from Oracle database. I manage the database with Oracle SQL Developer tool. There is a database called MCF01 created using Database Configuration Assistant with pluggable database also named MCF01.
I connect to it using SYSTEM and the admin password both inside Oracle SQL Developer tool and from my server:
Now I created a table named CM_ITM_ALL:
CREATE TABLE "SYS"."CM_ITM_ALL" ...
I can without a problem query inside CM_ITM_ALL from Oracle SQL Developer tool like so:
Problem
I cannot execute the same query SELECT ITM_NM FROM CM_ITM_ALL WHERE ITM_NUM='a800004' using my nodejs server. What is the problem here?
Here is the error message from the Oracle via my server:
[Error: ORA-00942: table or view does not exist] {
errorNum: 942,
offset: 19
}
Table does exist. Connection is not a problem as it is giving out the table does not exist error. Otherwise it would give out wrong credentials error.
What I tried
Appending SYS into the query: SELECT ITM_NM FROM SYS.CM_ITM_ALL WHERE ITM_NUM='a800004'
Quoting the table name inside the query to SELECT ITM_NM FROM 'SYS'.'CM_ITM_ALL' WHERE ITM_NUM='a800004'
Dev environment
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0
NodeJS v16.13.0
ExpressJs 4.17.2
node-oracledb 5.3.0
Oracle SQL Developer 21.4.2

IBM AS400 File not Found error while the Table Object is still there

I'm relatively new to working with remote IBM databases. I am connecting to a remote IBM AS400 database using an ODBC Python3 connector in an Anaconda virtual environment on Windows 10. My connection that successfully works is:
import pyodbc
connection = pyodbc.connect(
Driver='{iSeries Access ODBC Driver}',
System='<host>',
database='<database>',
uid='<username>',
pwd='<password>')
c1 = connection.cursor()
print('Connection established')
After connecting I run this command to see the list of tables:
c1.execute("select table_name from sysibm.sqltables")
And I see all the tables that I would need to query. But then when I try to query the contents of a specific table using:
c1.execute("select * from <database>.<table> LIMIT 100")
I get an error:
ProgrammingError: ('42S02', '[42S02] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0204 - <table> der Art *FILE in <database> nicht gefunden. (-204) (SQLExecDirectW)')
(It's in German, it means table of type *FILE in database not found)
(And I'm not using angle brackets, it's just for demonstration)
But a software like DBeaver returns valid data for both of them, for the tables list query and the specific table query. It's only python that gives the error.
Can anyone point out what could I be doing wrong? Or what can I run to pinpoint the problem?
<database>.<table> is not correct.
On Db2 you have
database
-schema
--table
you should be using <schema>.<table> as the database has been specified in the connection string.
<database>.<schema>.<table> is supported when connecting to a remote database from the "local" one...but only for basic selects. Db2 for IBM i doesn't support for example joining between a "local" and remote table.

Informatica workflow(MS SQL SERVER data source and target) fails error RR_4036"Data Source name not found and no default driver specified ."

I have windows 64bit and a Informatica client 32bit installed on it, so I added a DSN entry using the ODBC administrator for 32bit with driver native client "sql server" to connect to a Mssql 2008 R2 database on another pc. I added an entry in system DSN tab because informatica service is using System account. No problems when I have to import source and target in informatica using that ODBC DSN 32 bit "TARGET_DB_sciolto" (see odbc.ini below) entry. I build up my mapping and in the workflow session property than I change the connection from mssql server to ODBC.
The worflow is failing with same RR_4036 error.I think that the only thing I still have to try is to modify my ODBC.ini file since I read that I must add "enablequotedidentifiers=1" so I opened the file expecting to see a lot of entries but I only see following few lines and don't know what to do and would really appreciate if someone would help:
[ODBC 32 bit Data Sources]
test_infa=SQL Server Native Client 10.0 (32 bit)
TARGET_DB_sciolto=SQL Server (32 bit)
Target_DB=SQL Server (32 bit)
[test_infa]
Driver32=C:\WINDOWS\SysWOW64\sqlncli10.dll
[TARGET_DB_sciolto]
Driver32=C:\WINDOWS\system32\SQLSRV32.dll
[Target_DB]
Driver32=C:\WINDOWS\system32\SQLSRV32.dll
You need to set it up using lots of parameters. Please make sure you add the connection info in below format. Pls mention host,port,database at least. also make sure informatica machine has access to the datbase.
[TARGET_DB_sciolto]
Driver32=C:\WINDOWS\system32\SQLSRV32.dll
Description=DataDirect 7.1 SQL Server Wire Protocol
AlternateServers=
AlwaysReportTriggerResults=0
AnsiNPW=1
ApplicationName=
ApplicationUsingThreads=1
AuthenticationMethod=1
BulkBinaryThreshold=32
BulkCharacterThreshold=-1
BulkLoadBatchSize=1024
BulkLoadOptions=2
ConnectionReset=0
ConnectionRetryCount=0
ConnectionRetryDelay=3
Database=<database_name>
EnableBulkLoad=0
EnableQuotedIdentifiers=0
EncryptionMethod=0
FailoverGranularity=0
FailoverMode=0
FailoverPreconnect=0
FetchTSWTZasTimestamp=0
FetchTWFSasTime=1
GSSClient=native
HostName=<SQL_Server_host>
HostNameInCertificate=
InitializationString=
Language=
LoadBalanceTimeout=0
LoadBalancing=0
LoginTimeout=15
LogonID=
MaxPoolSize=100
MinPoolSize=0
PacketSize=-1
Password=
Pooling=0
PortNumber=<SQL_Server_server_port>
QueryTimeout=0
ReportCodePageConversionErrors=0
SnapshotSerializable=0
TrustStore=
TrustStorePassword=
ValidateServerCertificate=1
WorkStationID=
XML Describe Type=-10

Connection to Linked Access Database Using pyodbc

I am trying to get data from a Microsoft Access Database. The issue is the number of constraints I'm under:
I have to use 64 bit Python
The access database is made up of linked tables to a different database
The other database requires a 32 bit Oracle driver
Therefore, I have the Access Database stored locally and am trying to connect to that using PyODBC.
I've tried looking around and messing with the connection string but this problem seems pretty unique.
This is currently a modified version of what I have:
import pyodbc
dbPATH = r'C:\path\to\database.accdb'
UID = 'username'
PWD = 'username'
driver = r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
credentials = r'DBQ=%s;UID=%s;PWD=%s'%(dbPATH, UID, PWD)
conn_str = driver + credentials
connection = pyodbc.connect(conn_str)
cursor = connection.cursor()
cursor.execute("select * from [table_name];")
for row in cursor.fetchone():
print(row)
This is the error I typically get:
pyodbc.Error: ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver] ODBC--connection to '{Oracle in OraClient11g_home1_32bit}' failed. (-2001) (SQLExecDirectW)")
Which is surprising since this is the driver and connection that the access database uses to connect to the other data source.
I have tried setting
pyodbc.pooling = False
but that did not change anything.
You have two constraints that are mutually exclusive:
I have to use 64 bit Python
... and ...
The other database requires a 32 bit Oracle driver
64-bit processes cannot use 32-bit ODBC drivers; they are simply not compatible. If the rest of your stack (Oracle ODBC driver, Microsoft Office/Access application(s)) is 32-bit then you will need to use a 32-bit version of Python if you want to work with the linked tables as you've described.
Additional Note: Your statement that "The other database requires a 32 bit Oracle driver" is dubious. Client-server databases like Oracle, SQL Server, etc., don't particularly care if they receive requests from a 32-bit client or a 64-bit client. There may be differences in the details on the client side, but that's for the ODBC Driver (and/or the ODBC Driver Manager) on the client to figure out.

Resources