I am using pyodbc to query Hive. I also have access to a CLI for entering queries. When I enter the query in CLI, everything runs, but when I enter it in pydobc
cursor.execute(query)
results = cursor.fetchall()
I get this error:
Error: ('HY000', "[HY000] [Cloudera][HiveODBC] (35) Error from Hive: error code: '0' error message: 'java.io.IOException: java.io.EOFException'. (35) (SQLFetch)")
Sometimes it runs fine without giving this error, and sometimes it fails. I am at a loss as to what is causing this. It only happens when I select a subset of columns, not SELECT *.
The message from ODBC shows the "java.io.IOException: java.io.EOFException" which is an exception thrown in a Java stack. The error is very likely not originated from within the ODBC driver but in the server.
The ODBC driver communicates with Hive through the Thrift server (Hive Server 1 or Hive Server 2) but CLI by-passes the Thrift server. Have you try using beeline to reproduce this issue? Beeline uses the open-source JDBC driver to communicate with Hive through the Thrift server.
If this issue is also reproducible with beeline then the error might be originated from the Thrift server while fetching the results. In that case you may want to check the server logs for more details about the error. If you are using CDH you can check the HiveServer2 log in Cloudera Manager (I am guessing you are likely using Hive Server 2).
Cheers,
Holman
Related
I've been trying to connect to a MySQL database remotely but I keep getting the error:
2055: Lost connection to MySQL server at 'local.mysql.database.azure.com:3306', system error: 1 [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1045)
Using the exact same connection details I am able to connect to the database through MySQL Workbench and through Node. For some reason the connection won't go through in python.
This user's as not created to require SSL.
I've been trying to figure out the problem but I'm drawing blanks.
Below is my python login block.
config = {
'host':'local.mysql.database.azure.com',
'user':'user#local',
'password':'password',
'database':'random_db'
}
I've been able to connect to a MySQL instance on the Google Cloud Platform with the exact same connection block but it doesn't work for the Azure connection. I've looked for differences between the two platforms which could have caused this and the only thing I could find was that the Azure MySQL version was 5.7.32log while the GCP was 8.0.18.
I am also currently running python 3.7.0, not sure if that changes anything.
Is there another module I could use if that is the problem, or do I need to downgrade something? I have no idea.
According to this 5.7.29 is the latest 5.7 supported so 5.7.32 would give wrong version error.
I have a database on SQL Server which I had been connecting to in R without any trouble with the following connection string
dbhandle <- odbcDriverConnect('driver={SQL Server};server=XYZSERVERNAMEXYZ;database=mydatabase;trusted_connection=Yes')
Windows 10 just forced an update on me, and after re-booting, the connection fails with the message
[RODBC] ERROR: state HYT00, code 0, message [Microsoft][ODBC SQL Server Driver]Login timeout expired
SQL Server Management Studio works fine and connecting through the command prompt works as expected as well. I tried using python and pyodbc with a similar result.
It appears that in upgrading to the latest build of Windows (build 18362.267), TCP/IP got disabled by the updater. Going to SQL Server configuration manager and enabling TCP/IP fixes the problem.
Odd that the Windows updates have this kind of behaviour.
I have 2 machines setup:
RDP terminal with timesten client 11.2.1 and pyodbc==3.0.7 and works great. I use this connection string:
cnxn = pyodbc.connect('DSN=myhostip;UID=myusername;PWD=mypass')
local machine with timesten client 11.2.2 and pyodbc==4.0.22 (I've also tried older versions, like 3.0.7)
and when I use the connection string:
cnxn = pyodbc.connect('DSN=myhostip1;UID=myusername1;PWD=mypass1')
I get this error:
pyodbc.Error: ('HY010', u'[HY010] [Microsoft][ODBC Driver Manager] The driver is incapable of supporting the current environment attributes. (0) (SQLDriverConnect)').
Both databases on both machines are practically the same, so difference is only in timesten driver version.
Or what else could be the problem?
I have set up DSNs on both machines, and I connect to them in SQLDeveloper.
I've tried different timesten clients and pyodbc versions, but got same error everytime.
It's the only way that I know of to connect to timesten DB, can anyone please help me solve this error, or maybe tell about another way,except pyodbc, to connect?
See this answer on how to connect to TimesTen via Python:
python access to TimesTen
Use cx_Oracle via tnsnames.ora as this is the method that Oracle will support in TimesTen 18.1.3
Please avoid using any ODBC based method to connect to Python as none of these techniques are developed or tested by Oracle.
I can login to database in SQL Server Management Studio (SSMS) with the following:
However, in Python I tried
pymssql.connect(host='.\SQLSERVER', user='sa', password='1234', database='HastaneArsiv')
but I got the error message:
pymssql.InterfaceError: Connection to the database failed for an unknown reason.
In the SQL Server Configuration Manager i have verified that TCP/IP is enabled.
What could be the problem ?
There are lots of way can be solve this problem but nothing worked for me.I solved this problem install the Sql Server 2008R2 Service Pack 3 .
I am trying to connect using the pyodbc capability with the following connection string:
DRIVER={SQL Native Client}.
Getting the following error:
Error connecting to database: [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)
Main issue is that on my machine everything works like a charm, while execution on other machines return the error above.
Many thanks!
That is presumably because your connection string specifies some Windows datasource (a datasource is effectively an os-level alias) which exists on your machine, but does not exist on the other machines. You probably need to define the datasource on the other machines.
As Flipper suggests, first check out your connection string to determine what the name of the datasource is. Then check on your machine how that datasource is configured, then create and configure similar datasources on the other machines.
maybe check out the info and links on this ms dev-net page on datasources:
ODBC Data Source Administrator
All Windows installs include a copy of the older "SQL Server" ODBC driver
Driver={SQL Server}
so that should be available on any Windows machine for both 32-bit and 64-bit applications.
More recent versions of SQL Server have introduced their own client software to support their latest features. Drivers like
Driver={SQL Native Client} (9.0, for SQL Server 2005)
Driver={SQL Server Native Client 10.0} (for SQL Server 2008)
Driver={SQL Server Native Client 11.0} (for SQL Server 2012/2014)
will only work if the machine has the required SQL Server client software installed. (It can be downloaded and installed separately for machines that don't run SQL Server itself, usually as part of a "SQL Server Feature Pack".)
So, if you really need the more advanced features of the later "Native Client" ODBC driver then you will have to ensure that it gets installed on the other machines. Otherwise, just stick with the older "SQL Server" driver.