pyHive error TTransportException: Could not start SASL - python

I am trying to connect to remote hive using pyHive.
conn = hive.Connection(host='*********', port=10001, database='default', username='********',
auth='KERBEROS', kerberos_service_name='hive').cursor()
But I always got this error
**Notes: I already have the kerberos ticket
Is there something wrong with my configuration ?

Related

ORA-03135 connection lost contact while trying to connect to DB using python and cx_Oracle module

I'm trying to connect to the oracle db using cx_Oracle and python on Windows 10 system (based on https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html#installing-cx-oracle-on-windows) like below:
import cx_Oracle
dsn_tns = cx_Oracle.makedsn('host', 'port', service_name='name')
conn = cx_Oracle.connect(user='username', password='passwd', dsn=dsn_tns)
And i've got an error:
cx_Oracle.OperationalError: ORA-03135: connection lost contact
Process ID: 0
Session ID: 0 Serial number: 0
I've also add 2 parameters to sqlnet.ora (based on info from: https://www.vitalsofttech.com/ora-03135-connection-lost-contact/):
SQLNET.EXPIRE_TIME=10
SQLNET.INBOUND_CONNECT_TIMEOUT=3
Still raising the same error.
I was thinking that maybe it can be a problem with firewall, but it's not. Also I can connect to database from command line using sqlplus.
Tnsping to the database from my local machine returns OK.
Problem solved.
Upgrading Oracle instant client on my local machine from 11.2 to 12.1 solved the problem of connectivity.

Python pymssql - Connecting to Named Instance

I'm trying to connect to a SQL Server named instance from python 3.4 on a remote server, and get an error.
File "C:\Scripts\Backups Integrity Report\Backup Integrity Reports.py", line 269, in
conn = pymssql.connect(host=r'hwcvcs01\HDPS', user='My-office\romano', password='PASS', database='CommServ')
File "pymssql.pyx", line 636, in pymssql.connect (pymssql.c:10178)
pymssql.OperationalError: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed\n')
Other SQLs are connected without a problem. Also I manage to connect to the SQL using the Management Studio, from the same remote server.
Tried different ports, tried to connect to the host itself rather than the instance, and also tried pypyodbc.
What might be the problem?
For a named instance that looks like this:
myhost\myinstance,1435
You can connect via pymssql with the following:
pymssql.connect(host='myhost', server='myinstance', port='1435', user='user', password='pw')
According to the pymssql documentation on the pymssql Connection class, for a named instance containing database theDatabase, looking like this:
myhost\myinstance
You could connect as follows:
pymssql.connect(host=r'myhost\myinstance', database='theDatabase', user='user', password='pw')
The r-string is a so-called raw string that does not treat the '' as an escape.

MySQL-python not executing in CGI

I am working with MySQL-python package. I am able to execute MySQL dependent scripts from command line, however doing the same through browser (Apache CGI) yields the following error:
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/var/www/html/temp.py in ()
9
10 # Establich a connection
11 db = MySQLdb.connection(host="127.0.0.1", user="root", passwd="", db="inserv")
12
13 # Run a MySQL query from Python and get the result set
db undefined, MySQLdb = <module 'MySQLdb' from
'/usr/lib64/python2.6/site-packages
/MySQLdb/__init__.pyc'>, MySQLdb.connection = <type '_mysql.connection'>,
host undefined, user undefined, passwd undefined
<class '_mysql_exceptions.OperationalError'>:
(2003, "Can't connect to MySQL server on '127.0.0.1' (13)")
args = (2003, "Can't connect to MySQL server on '127.0.0.1' (13)")
message = ''
I have been stuck in this situation for past few days. MySQL commands issued through php based sites execute appropriately and I can, also, login to MySQL from command line. The problem seem to be with Python CGI only.
I have also tried the same with oursql package and there seems to be a similar problem. How can I address this situation?
Edit
As per #Real's answer I have edited my code to use MySQLdb.connect() but the problem still persist and traceback ends with:
2003, "Can't connect to MySQL server on '127.0.0.1' (13)"
You should be using connect, not connection. Mysqldb.connect() returns a connection object but you appear to be calling mysqldb.connection(). See The docs for an example of how to do it.

How to connect to remote mysql server in python

Hi i have a requirement where i need to connect to remote mysql server. My application shall be running on local machine and my mysql will be running on remote server.I have tried the following code:
DB = 'gts'
DB_HOST = 'ps95074.dreamhost.com'
DB_USER = 'root'
DB_PASSWORD = 'dbadminpassword'
conn = MySQLdb.Connection(db=DB, host=DB_HOST, user=DB_USER,passwd=DB_PASSWORD)
cursor = conn.cursor()
But i am getting the following error
OperationalError: (2005, "Unknown MySQL server host 'ps95074.dreamhost.com' (1)")
Instead if i use
DB_HOST='localhost'
Everything works fine. How can same be possible with remote host.Any help shall be appreciated.
Check your firewall. That server is online and available from any machines:
> mysql -h ps95074.dreamhost.com
ERROR 1045 (28000): Access denied for user 'myuser'#'myhost' (using password: NO)
However, even if you can connect chances are good that your database user only allows local connections.
Update: I just tried it again and now it also fails using the commandline client. So clearly something is wrong with your server.

Python - Linux - Connecting to MS SQL with Windows Credentials - FreeTDS+UnixODBC + pyodbc or pymssql

There doesn't seem to be any great instructions for setting this up. Does anyone have any good instructions? I am a linux noob so be gentle. I did see another post that is similar, but no real answer.
I have a couple of problems.
FreeTDS doesn't "seem" to be working. I am trying to connect and I get the following message using the "tsql" command: "Default database being set to databaseName
There was a problem connecting to the server" but it doesn't mention what the problem is.
The error I get when I try to connect using pyodbc is: "pyodbc.Error: ('08S01', '[08S01] [unixODBC][FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist (20009) (SQLDriverConnectW)')"
I tried something similar with pymssql, but I ran into similar issues. I keep getting errors that I can't connect, but it doesn't tell me why.
The following works if you configure the MS SQL server to allow remote TCP/IP connections and have an appropriate user to connect as.
You also need to be careful to set up the correct hostname for the db as reported by MS SQL.
import pymssql
connection = pymssql.connect(
user = 'username',
password = 'password',
host = 'server',
database = 'database',
)
cursor = connection.cursor()
cursor.execute('select * from db;')
rows = cursor.fetchall()
When building FreeTDS (http://www.freetds.org/userguide/config.htm):
./configure --with-tdsver=8.0 --enable-msdblib
That error suggests that the TDS version is not set right. You can set that in the configuration setting for FreeTDS. You don't mention which MSSQL version you are using. But, if you are using say 2005, setting 8.0 as the TDS version will work.

Categories

Resources