Can anyone explain the following stack trace, in step by step, please?
I want to find out what the root cause of the error is and where the error originates from.
Traceback (most recent call last):
1. File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensio ns\Microsoft\Python Tools for Visual Studio\2.1\visualstudio_py_util.py", line 1 06, in exec_file
exec_code(code, file, global_variables)
2. File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensio ns\Microsoft\Python Tools for Visual Studio\2.1\visualstudio_py_util.py", line 8 2, in exec_code
exec(code_obj, global_variables)
3. File "C:\Users\ssr\FindAllCandidatePathsOfTrain.py", line 332, in <module>
main()
4. File "C:\Users\ssr\FindAllCandidatePathsOfTrain.py", line 296, in main
stanoxDetails = checkTheLineHasStanox(lastLineSegment)
5. File "C:\Users\ssr\FindAllCandidatePathsOfTrain.py", line 205, in checkTheLineHasStanox
firstrow= query(queryStr, 'GetOne')
6. File "C:\Users\ssr\FindAllCandidatePathsOfTrain.py", line 45, in query
connection.close()
7. File "C:\Python34\lib\site-packages\pypyodbc.py", line 2658, in close
self.rollback()
8. File "C:\Python34\lib\site-packages\pypyodbc.py", line 2581, in rollback
check_success(self, ret)
9. File "C:\Python34\lib\site-packages\pypyodbc.py", line 988, in check_success
ctrl_err(SQL_HANDLE_DBC, ODBC_obj.dbc_h, ret, ODBC_obj.ansi)
10. File "C:\Python34\lib\site-packages\pypyodbc.py", line 966, in ctrl_err
raise DatabaseError(state,err_text) pypyodbc.DatabaseError: ('08S01', '[08S01] [Microsoft][ODBC SQL Server Driver]Co mmunication
link failure')
Press any key to continue . . .
The traceback shows you the lines of code executed before the error occurred and the error itself, as mentioned. Python isn't the direct cause of the error in this case.
Consider:
10. File "C:\Python34\lib\site-packages\pypyodbc.py", line 966, in ctrl_err
raise DatabaseError(state,err_text) pypyodbc.DatabaseError: ('08S01', '[08S01] [Microsoft][ODBC SQL Server Driver]Communication link failure')
What this shows is that this error in Python is a "pass-through" error. The database driver being called is actually the cause of the error, and Python is simply passing that through Python. Good luck.
A Python Traceback will show you what was being executed before the error occured as well as the line it error-ed on.
In this case, your module raised an error on this line:
File "C:\Python34\lib\site-packages\pypyodbc.py", line 966, in ctrl_err
raise DatabaseError(state,err_text)
And the error text is shown here:
pypyodbc.DatabaseError: ('08S01', '[08S01] [Microsoft][ODBC SQL Server Driver]Communication link failure')
Related
So I'm using MySQL connector and I'm getting an error which is weird because I didn't get any errors with this line before. Please let me know what the issue is.
def update(Sno,Passengers,Distance,Cargo,Aircraft):
myconn=mys.connect(host='localhost',user='root',passwd='adis',database='adis')
if myconn.is_connected():
print('Connection successful')
mycur=myconn.cursor()
query="update AMAS set Passengers={},Distance={},Cargo={},Aircraft={} where Sno={}".format(Passengers,Distance,Cargo,Aircraft,Sno)
mycur.execute(query)
myconn.commit()
print("AMAS Aircraft Database updated")
My error:
Connection successful
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\vinayak\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:\Users\vinayak\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 3442, in __call__
self.__callback(self.__value, *args)
File "C:\Users\vinayak\Documents\Programs 12th\Project.py", line 146, in exe
submit()
File "C:\Users\vinayak\Documents\Programs 12th\Project.py", line 127, in submit
update(Sno,Passengers,Distance,Cargo,Aircraft)
File "C:\Users\vinayak\Documents\Programs 12th\Project.py", line 135, in update
mycur.execute(query)
File "C:\Users\vinayak\AppData\Roaming\Python\Python37\site-packages\mysql\connector\cursor.py", line 551, in execute
self._handle_result(self._connection.cmd_query(stmt))
File "C:\Users\vinayak\AppData\Roaming\Python\Python37\site-packages\mysql\connector\connection.py", line 490, in cmd_query
result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
File "C:\Users\vinayak\AppData\Roaming\Python\Python37\site-packages\mysql\connector\connection.py", line 395, in _handle_result
raise errors.get_exception(packet)
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Distance=,Cargo=,Aircraft= where Sno=' at line 1
Also, I'm new to Stack Overflow so please mention how I can improve asking questions here withput frustrating others.
I've caught a problem I can't explain using pygresql for python. This is a simple SELECT query and as far as I can tell the only query that has the problem in the whole script.
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "run_daily_script.py", line 122, in DelegateAPINodes
vm_api_group = Execute(db_conn, fetch_api_group, (cust_id, nodes["node_id"]))
File ".../PreparedQueries.py", line 14, in Execute
result = db.execute(command)
File "/usr/local/lib/python2.7/site-packages/pgdb.py", line 1030, in execute
return self.executemany(operation, [parameters])
File "/usr/local/lib/python2.7/site-packages/pgdb.py", line 1065, in executemany
raise _op_error("Internal error in '%s': %s" % (sql, err))
OperationalError: Internal error in 'SELECT * FROM vm_api_group WHERE cust_id=3 AND node_id=18': insufficient data in "T" message
I ran the query via the console and it works just fine. I monitored psql logs and there were no errors from the database. It seems to be an internal operation with pygresql.
What does "T" mean and how do I fix this?
Using parallel-ssh module I'm trying to run SSH commands using Natinve Client but getting SessionHandshakeError. And if I use Paramiko Client instead, everything works fine. I met the requirement of my_pkey.pub being in the same directory as my_pkey.
Here is my code which uses Native Client (changed real IPs to 'ip1' and 'ip2'):
from pssh.pssh2_client import ParallelSSHClient
pkey = os.path.dirname(os.path.abspath(__file__)) + '/my_pkey'
hosts = ['ip1', 'ip2']
client = ParallelSSHClient(hosts, user='root', pkey=pkey)
output = client.run_command('hostname')
for host, host_output in output.items():
for line in host_output.stdout:
print(line)
Getting this error:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\ssh2_client.py", line 123, in _init
self.session.handshake(self.sock)
File "ssh2\session.pyx", line 81, in ssh2.session.Session.handshake
ssh2.exceptions.SessionHandshakeError: ('SSH session handshake failed with error code %s', -5)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\ssh2_client.py", line 123, in _init
self.session.handshake(self.sock)
File "ssh2\session.pyx", line 81, in ssh2.session.Session.handshake
ssh2.exceptions.SessionHandshakeError: ('SSH session handshake failed with error code %s', -5)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\ssh2_client.py", line 123, in _init
self.session.handshake(self.sock)
File "ssh2\session.pyx", line 81, in ssh2.session.Session.handshake
ssh2.exceptions.SessionHandshakeError: ('SSH session handshake failed with error code %s', -5)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/NazimokPP/Desktop/AnchorFree/QA-Automation/nodetest/nodetest.py", line 57, in <module>
main(args.server_domain, args.test_type)
File "C:/Users/NazimokPP/Desktop/AnchorFree/QA-Automation/nodetest/nodetest.py", line 45, in main
output = client.run_command('hostname')
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\pssh2_client.py", line 182, in run_command
encoding=encoding, use_pty=use_pty, timeout=timeout)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\base_pssh.py", line 91, in run_command
self.get_output(cmd, output)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\base_pssh.py", line 136, in get_output
(channel, host, stdout, stderr, stdin) = cmd.get()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\greenlet.py", line 482, in get
self._raise_exception()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\greenlet.py", line 159, in _raise_exception
reraise(*self.exc_info)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\_compat.py", line 33, in reraise
raise value.with_traceback(tb)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\greenlet.py", line 536, in run
result = self._run(*self.args, **self.kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\pssh2_client.py", line 188, in _run_command
self._make_ssh_client(host)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\pssh2_client.py", line 313, in _make_ssh_client
allow_agent=self.allow_agent, retry_delay=self.retry_delay)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\ssh2_client.py", line 107, in __init__
THREAD_POOL.apply(self._init)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\pool.py", line 325, in apply
return self.spawn(func, *args, **kwds).get()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\event.py", line 385, in get
return self.get(block=False)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\event.py", line 375, in get
return self._raise_exception()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\event.py", line 355, in _raise_exception
reraise(*self.exc_info)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\_compat.py", line 33, in reraise
raise value.with_traceback(tb)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\gevent\threadpool.py", line 211, in _worker
value = func(*args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\ssh2_client.py", line 126, in _init
return self._connect_init_retry(retries)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\ssh2_client.py", line 116, in _connect_init_retry
return self._init(retries=retries)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\ssh2_client.py", line 126, in _init
return self._connect_init_retry(retries)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\ssh2_client.py", line 116, in _connect_init_retry
return self._init(retries=retries)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pssh\ssh2_client.py", line 128, in _init
raise SessionError(msg, self.host, self.port, ex)
pssh.exceptions.SessionError: ('Error connecting to host %s:%s - %s', 'ip1', 22, SessionHandshakeError('SSH session handshake failed with error code %s', -5))
Process finished with exit code 1
Here is my code which uses Paramiko Client (changed real IPs to 'ip1' and 'ip2'):
from pssh.pssh_client import ParallelSSHClient
from pssh.utils import load_private_key
key_path = os.path.dirname(os.path.abspath(__file__)) + '/my_pkey'
pkey = load_private_key(key_path)
hosts = ['ip1', 'ip2']
client = ParallelSSHClient(hosts, user='root', pkey=pkey)
output = client.run_command('hostname')
for host, host_output in output.items():
for line in host_output.stdout:
print(line)
And it works. Here's the output (should I care about warnings?):
C:\Program Files (x86)\Python36-32\lib\site-packages\paramiko\ecdsakey.py:202: CryptographyDeprecationWarning: signer and verifier have been deprecated. Please use sign and verify instead.
signature, ec.ECDSA(self.ecdsa_curve.hash_object())
C:\Program Files (x86)\Python36-32\lib\site-packages\paramiko\rsakey.py:110: CryptographyDeprecationWarning: signer and verifier have been deprecated. Please use sign and verify instead.
algorithm=hashes.SHA1(),
ip1.hostname
ip2.hostname
Process finished with exit code 0
What am I doing wrong with Native Client?
This error was tracked down to the WinCNG back-end used for libssh2 on Windows - it does not support SHA-256 host key hashes which is now the default in recent versions of OpenSSH server.
The latest version of parallel-ssh, 1.6.0, fixes this issue by switching the Windows back-end to OpenSSL for better compatibility and to match the OSX and Linux binary wheels.
See release notes for more details.
Some explanations which I got from Panos in Google Groups thread. It didn't help me, but maybe it will be helpful for somebody else.
A -5 error is defined as a key exchange error in libssh2. It sounds
like the key type is not supported by libssh2 and paramiko shows
'ecdsakey.py' being used. ECDSA keys are not currently supported by
libssh2 (PR pending).
The warning are from paramiko itself, can't say if they matter.
Better exceptions for native client errors are being worked on for
next release.
_
So for a private key 'my_pkey', there should be a 'my_pkey.pub' in
same directory.
It may also be a case of the SSH server's key not being supported by
the native client (same limitations as user keys) which would explain
the key exchange error. Can check the type of key configured for the
server in /etc/ssh/sshd_config, HostKey entry. There should be at
least one non-ECDSA key configured, eg:
HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
If there is only a ECDSA key entry, the native client will not be able
to connect.
Here is the code
import pymysql
pymysql.connect(
host='localhost',
port=3306,
user='root',
password='iDontWannaSay',
db='iDontWannaShow',
charset='utf8'
)
and the error Traceback was:
data is :::::b'\xff\x02\x00\xff\x81\x15'....##### I was add near line 1279 which is print("data is :::::%s...."%data[i:i+6])
Traceback (most recent call last):
File "C:\Users\123\Desktop\pymysqldebug.py", line 8, in <module>
charset='utf8'
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\__init__.py", line 90, in Connect
return Connection(*args, **kwargs)
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\connections.py", line 709, in __init__
self.connect()
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\connections.py", line 934, in connect
self._get_server_information()
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\connections.py", line 1279, in _get_server_information
self.server_charset = charset_by_id(lang).name
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\charset.py", line 39, in by_id
return self._by_id[id]
KeyError: 255
seems like struct.unpack method parse '\xff\' to 255 and assigned to self.server_language, whatever the non-null charset argument passed.
Is this an MySQL version problem?(version 8.0.1-dmr)
To extend the above link-only accepted answer, consider the following changes on your current pymysql install. With MySQL 8, the mysql-python API does not recognize possibly newer character sets and hence the raised KeyError.
To resolve, locate the connectors.py script under the pymysql module found at this directory:
print(pymysql.__file__)
Backup orginal connectors.py script. Then incorporate the following changes.
Original (lines 1268-1269)
self.server_language = lang
self.server_charset = charset_by_id(lang).name
Replace (lines 1268 - 1272)
self.server_language = lang
try:
self.server_charset = charset_by_id(lang).name
except KeyError:
self.server_charset = None
Be careful to include hidden tabs in indentation with above lines.
Reference
PyMySQL Git fix #591
but where's your variable?
import pymysql
|
v
myVariable = pymysql.connect(
host='localhost',
port=3306,
user='root',
password='iDontWannaSay',
db='iDontWannaShow',
charset='utf8'
)
I am trying to fetch 150 million rows with messages data from data warehouse into my EC2 instance. I have 90GB available space on my disk. When I put my query for running, following is the error I get:
Traceback (most recent call last):
File "/usr/local/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/result.py", line 964, in fetchall
l = self.process_rows(self._fetchall_impl())
File "/usr/local/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/result.py", line 915, in _fetchall_impl
return self.cursor.fetchall()
pyodbc.Error: ('08S01', '[08S01] [FreeTDS][SQL Server]Read from the server failed (20004) (SQLFetch)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "en_str.py", line 45, in <module>
INNER JOIN notified.Message m ON c.MessageID = m.MessageID where c.CreateDate>'2016-01-01 00:00:00.0';''',db007_cnxn)
File "/usr/local/anaconda/lib/python3.5/site-packages/pandas/io/sql.py", line 331, in read_sql_query
parse_dates=parse_dates, chunksize=chunksize)
File "/usr/local/anaconda/lib/python3.5/site-packages/pandas/io/sql.py", line 1092, in read_query
data = result.fetchall()
File "/usr/local/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/result.py", line 970, in fetchall
self.cursor, self.context)
File "/usr/local/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
exc_info
File "/usr/local/anaconda/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 202, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/anaconda/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 185, in reraise
raise value.with_traceback(tb)
File "/usr/local/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/result.py", line 964, in fetchall
l = self.process_rows(self._fetchall_impl())
File "/usr/local/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/result.py", line 915, in _fetchall_impl
return self.cursor.fetchall()
sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('08S01', '[08S01] [FreeTDS][SQL Server]Read from the server failed (20004) (SQLFetch)')
My disk space gets full and odbc.log file in tmp folder is taking 90GB space. I have another mounted disk with 100TB space but odbc.log is generated only in tmp folder. What is the solution for this? Any thoughts on how this problem can be solved? Alternatively, how can I change odbc.log file location from 100 GB space disk to the disk with 100 TB space?
Also, instead of giving ec2 instance location, if I give s3 bucket location, will that avoid this odbc.log file?
Any help would be appreciated!
It looks like you may have verbose FreeTDS logging on. Most of the time, the config file is located in /etc/freetds.conf or /etc/freetds/freetds.conf.
You'll want to look for dump file in the FreeTDS log. Also, check odbcinst.ini, as logging can be turned on there.
You'll probably find one of the various logging facilities pointing to /tmp/odbc.log and that'll be your culprit. Good luck!