Pyodbc Hive connection error in Python - python-3.x

I am trying to connect to the Hive from Python with Pyodbc ,I have installed "ODBC driver for apache hive" and I did configured everything and the connection is good.
When I am trying to execute my query through pyodbc,i am getting below error.
I tried with "use native query " option in driver configuration ,and also given the schema name,but it is still showing the same error.
Error
pyodbc.ProgrammingError: ('42S02', '[42S02] [Cloudera][SQLEngine] (31740) Table or view not found:
Thank you

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.

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.

Problem with connecting to MS SQL Server with Python AWS Lambda Layer - ODBC Driver 13 for SQL Server

I am in the process of setting up an AWS lambda function to connect to a MS SQL Server database using pyodbc to extract records from a table.
I am receiving an error message
('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found (0) (SQLDriverConnect))
I have built a deployment package on a linux EC2 instance) using the process detailing in the following post:
https://gist.github.com/carlochess/658a98589709f46dbb3d20502e48556b
I have read extensively on this and have changed the path in the odbcinst.ini file to match the directory structure of the lambda layer, but with no luck.
I have also directory referenced the location of the driver file (libmsodbcsql-13.1.so.9.2).
The error message changes slightly to state that it cannot find the driver efile at the certain location(even though the file does exist)
If you're using pyodbc in a layer, lambda will look for the odbc driver on /opt instead of /var/task. That's probably why you get an error with file not found.
Take a look at the following link on how to get pyodbc as a lambda layer

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

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.

Unable to query SQL server 2008 databse from linux?

I have written a JAVA SPRING RESTFUL web-service to query SQL server 2008 database using sqljdbc4 driver. It works fine from windows machine, but when I deploy the code to a Linux box I am not be to execute both select and insert queries.
I tried using “SET NOCOUNT ON”, but no luck.
Error while executing select query
org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [ Select statement ………. );]; SQL state [null]; error code [0]; The statement did not return a result set.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.
Error while executing insert query
org.springframework.dao.DataAccessResourceFailureException: PreparedStatementCallback; SQL [Insert into log(id, datetime) values(?,?)]; SQL Server did not return a response. The connection has been closed.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: SQL Server did not return a response. The connection has been closed.
JDBC driver POM dependency.
com.microsoft.sqlserver
sqljdbc4
4.0
I tried some other stuff that I read on google but no luck. If some can point me to a right direction, I would really appreciate help.
Try using jtds driver instead of microsoft jdbc driver.

Resources