Connection to SQL Server fails after Windows 10 update - python

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.

Related

pymssql "InterfaceError: Connection to the database failed for an unknown reason."

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 .

Error in ODBC but not in CLI for Hive?

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

pyodbc error: Data source name not found (Win8)

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.

MySQL Connect, XAMPP and ODBC

Note:**I am connecting using Python2.7 in a virtualenv to access MySQL on XAMPP, which was not installed on the virtualenv.
I am trying to connect with MySQL via python. I recently downloaded MySQL connect from Oracle. I also downloaded the ODBC driver from the same site. When I plug in the information below, I get a 2003 error telling me that it cannot connect:
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1'
but when I include the port number in my connection, it freezes up and nothing happens.
This is my code:
>>>import mysql.connector
>>>cnx = mysql.connector.connect(user='[my username]',password='[my password]',host='127.0.0.1', database='FXPrices',port=80)
After that, the cursor indents--so there are no arrows for the python prompt. I have to hit control-z every time I want it to stop. Do I need mod_wsgi to fix this?
You're trying to connect to the http port (port 80) on your machine.
MySQL by default listens to port 3306, you shoud try that (it's the same if you omit the port argument), or try to find out on which port your mysql server is really listening.

Cant Connect to remote MS SQL server using PYODBC on Windows 7 in Python

So I am having some issues trying to connect to my server that is hosted on my network but on a different computer to the program I am trying to run. I have checked and both computers are on the same domain. I am coding in python and using PYODBC to make the connection.
The connect line is as follows:
connectLine = 'DRIVER={SQL Native Client};SERVER='+configValues['host']+';DATABASE='+configValues['db']+';UID='+configValues['user']+';PWD='+configValues['passwd']
db = pyodbc.connect(connectLine)
Now that works when the server is on the same computer as the program, but when I try to connect to the server on my actual server it doesnt work. I am running MicrosoftSQL Express 2005 on Windows SBS 2003 and the computer running the program is running Windows 7 with the program coded in Python 2.7
This is the output of the program, I have it printing the connect line.
DRIVER={SQL Native Client};SERVER=192.168.1.103\OSBORNE;DATABASE=vpmser;UID=massEmailer;PWD=cogbutfeswas5836;
Traceback (most recent call last):
File "E:\Mass Emailer\massEmailer.py", line 56, in <module>
db = pyodbc.connect(connectLine)
Error: ('08001', '[08001] [Microsoft][SQL Native Client]SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. (-1) (SQLDriverConnectW); [HYT00] [Microsoft][SQL Native Client]Login timeout expired (0); [08001] [Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (-1)')
Some possibilities:
(1) About this part of your connection string: SERVER=192.168.1.103\OSBORNE; ... part of the definitely-non-generic error message says """Error Locating Server/Instance Specified"""
A note from connectionstrings.com:
"""Are you using SQL Server 2005 Express? Don't miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2005 Express installation resides."""
If OSBORNE is not the name of the remote server, what is it? Why do you include an IP address?
Perhaps you should have OSBORNE\SQLEXPRESS instead of 192.168.1.103\OSBORNE
(2) Down the end of the error message, it says """When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.""" ... Have you checked that (a) SQL Server Express supports remote connections (b) it is configured to allow remote connections?
(3) Can you access the database remotely using (a) a remote logon to the server machine with the userid and password that you are using (b) a query tool that you run on the client machine and uses a DSN to point to the remote machine & database? If so, how do the connection parameters differ from what you have in your connection string?

Categories

Resources