Airflow Connection pymssql - python

I accidently remove some folders from linux that have informations from DB, idk what i did, but i cant do my Dags work. Look the error:
Broken DAG: [/home/airflow/airflow/dags/etlSFX.py] Traceback (most recent call last):
File "src/pymssql/_mssql.pyx", line 1817, in pymssql._mssql.maybe_raise_MSSQLDatabaseException
File "src/pymssql/_mssql.pyx", line 1834, in pymssql._mssql.raise_MSSQLDatabaseException
pymssql._mssql.MSSQLDatabaseException: (20009, b'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (192.168.100.36)\nNet-Lib error during Connection refused (111)\nDB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (192.168.100.36)\nNet-Lib error during Connection refused (111)\n')

Related

connection refused while using firebirdsql to connect localhost fdb file

I'm trying to read fdb files in Ubuntu using firebirdsql:
conn = firebirdsql.connect(host='localhost', database='db.fdb',
user='sysdba', password='masterkey', charset='utf8')
But while connecting, it just said Connection refused.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/.local/lib/python3.6/site-packages/firebirdsql/__init__.py", line 94, in connect
conn = Connection(**kwargs)
File "~/.local/lib/python3.6/site-packages/firebirdsql/fbcore.py", line 595, in __init__
self.sock = SocketStream(self.hostname, self.port, self.timeout, cloexec)
File "~/.local/lib/python3.6/site-packages/firebirdsql/socketstream.py", line 46, in __init__
self._sock = socket.create_connection((host, port), timeout)
File "/usr/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
the code works well on Windows Server, but on Ubuntu it can't establish the connection, how can I solve it?
In the comments you indicate you don't have a Firebird server installed on your machine. As there is no server listening on localhost port 3050, you get the connection refused error.
That firebirdsql, the driver you're using, is pure Python doesn't mean it can open database files by itself, it means it doesn't use a native library to establish a connection, but that it implements the Firebird TCP/IP wire protocol in Python. You will need a Firebird server (either localhost or remotely) to connect to.
Also: a server normally won't be able to access files in your home directory.

connect to remote sql server database using python from linux with windows auth

I have an MS SQL Server running on my server machine,
i want to connect to the server using python running on my linux machine.
i have tried to use pyodbc
connect('Driver={SQL Server};'
'Server=ip;'
'Database=db;'
'Trusted_Connection=True;')
Traceback (most recent call last):
File "<input>", line 1, in <module>
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")
and with pymssql i got this issue
>>> import pymssql
>>> conn = pymssql.connect(server="ip", user="user", password="password", database="database")
Traceback (most recent call last):
File "src/pymssql.pyx", line 636, in pymssql.connect
File "src/_mssql.pyx", line 1964, in _mssql.connect
File "src/_mssql.pyx", line 682, in _mssql.MSSQLConnection.__init__
File "src/_mssql.pyx", line 1690, in _mssql.maybe_raise_MSSQLDatabaseException
_mssql.MSSQLDatabaseException: (18456, b"Login failed for user 'user'.DB-Lib error message 20018, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (ip)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (ip)\n")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "src/pymssql.pyx", line 642, in pymssql.connect
pymssql.OperationalError: (18456, b"Login failed for user 'user'.DB-Lib error message 20018, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (ip)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (ip)\n")

Connection refused when trying to create a connection

We are using django to call APIs (ubuntu server) that are on 172.20.44.148.
Our code is the following:
import socket
socket.create_connection(('172.20.44.148', 8080), timeout=2)
However, the connection refused.
This is the error we got from apache:
[root#xxx ~]# python /home/something.py
Traceback (most recent call last):
File "/home/something.py", line 3, in <module>
socket.create_connection(('172.20.44.148', 8080), timeout=2)
File "/usr/local/lib/python2.7/socket.py", line 571, in create_connection
raise err
socket.error: [Errno 111] Connection refused
We also tried to ping 172.20.44.148 and we got a response.
Any ideas?

connection refused error in paho-mqtt python package

I am new to paho-mqtt. I was trying to publish a topic using my localhost and I encountered the following error :
Traceback (most recent call last):
File "server.py", line 10, in <module>
client1.connect(host,port,keepalive)
File "/usr/local/lib/python2.7/dist-packages/paho_mqtt-1.3.1-py2.7.egg/paho/mqtt/client.py", line 768, in connect
return self.reconnect()
File "/usr/local/lib/python2.7/dist-packages/paho_mqtt-1.3.1-py2.7.egg/paho/mqtt/client.py", line 895, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python2.7/socket.py", line 575, in create_connection
raise err
socket.error: [Errno 111] Connection refused
My python code is below :
import paho.mqtt.client as paho
port=1883
host = "localhost"
keepalive = 60
def on_publish(client,userdata,result):
print("data published \n")
pass
client1= paho.Client("control1")
client1.on_publish = on_publish
client1.connect(host,port,keepalive)
ret= client1.publish("Robot","Robot 1 move_left")
When I run the same code with iot.eclipse.org as host then it works fine. Any help would be highly appreciated.
I was facing the same issue.
The solution was to install a local MQTT broker.
http://www.steves-internet-guide.com/install-mosquitto-linux/
The exposed docker port for mqtt is usually different than 1883.
I use the official eclipse mosquitto docker and the run example on their page is something like:
sudo docker run -it -p 11883:1883 -p 9001:9001 eclipse-mosquitto
therefore the client should connect to port 11883
client.connect(broker_address, 11883)

pymongo : Unable to connect to mongolab

I am getting this error while trying to connect to mongolab. I am using pymongo-2.8 as mentioned in some of other answers.
connection=MongoClient("mongodb://usr:pass#host:port/data")
StackTrace:
Traceback (most recent call last):
File "C:\chrome_addon\database_update.py", line 5, in <module>
connection=MongoClient("mongodb://user:pass#host:port/data")
File "C:\Python27\lib\site-packages\pymongo\mongo_client.py", line 377, in __init__
raise ConnectionFailure(str(e))
pymongo.errors.ConnectionFailure: [Errno 10061] No connection could be made because the target machine actively refused it
[Finished in 1.6s with exit code 1]
I also tried accessing it with command line, it is failing.
mongo ds031711.mongolab.com:31711/data -u <dbuser> -p <dbpassword>
Stacktrace:
MongoDB shell version: 3.0.5
connecting to: ds031711.mongolab.com:31711/data
2015-10-02T10:40:21.662+0530 W NETWORK Failed to connect to 54.159.76.238:31711
, reason: errno:10061 No connection could be made because the target machine act
ively refused it.
2015-10-02T10:40:21.670+0530 E QUERY Error: couldn't connect to server ds0317
11.mongolab.com:31711 (54.159.76.238), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed
URI and username,password are correct.

Categories