When I do a query with isql I get the following message and the query blocks.
The transaction log in database foo is almost full. Your transaction is being suspended until space is made available in the log.
When I do the same from Python:
cursor.execute(sql)
The query blocks, but 开发者_JS百科I would like see this message.
I tried:
Sybase.set_debug(sys.stderr)
connection.debug = 1
I'm using:
- python-sybase-0.40pre1
- Adaptive Server Enterprise/15.5/EBF 18164
EDIT: The question is, "How do I capture this warning message in the python program?"
Good question and I'm not sure I can completely answer it. Here are some ideas.
Sybase.py uses logging. Make sure you are using it. To "bump" the logging out I would do this:
import logging
logging.basicConfig(level = logging.INFO,
format = "%(asctime)s %(levelname)s [%(filename)s] (%(name)s) %(message)s",
datefmt = "%H:%M:%S", stream = sys.stdout)
log = logging.getLogger('sybase')
log.setLevel(logging.DEBUG)
And apparently (why is beyond me??) to get this working in Sybase.py you need to set a global DEBUG=True
(see line 38)
But then if we look at def execute
we can see (as you point out) that it's blocking. We'll that sort of answers your question. You aren't going to get anything back as it's blocking it. So how do you fix this - write a non-blocking excute method;) There is some hints in examples/timeout.py. Apparently someone else has run up on this but hasn't really fixed it.
I know this didn't probably help but I spent 15 minutes looking - I should at least tell you what I found.. You would think that execute
would give you some result
-- Wait what is the value of result in line 707??
while 1:
status, result = self._cmd.ct_results()
if status != CS_SUCCEED:
break
If status != CS_SUCCEED (which I'm assuming in your case is True) can you simply see what "result" is equal to? I wonder if they just failed raise the result as an exception?
Your query may be large which is overflowing the transaction log (e.g. you are inserting large binary files). Or you may not be truncating your transaction logs often enough if that's an option.
During runtime you will want to have an except statement that catches the exception Error.
See the Sybase Python documentation.
The reason is obvious, transaction log is full, you can check the blocikng queries in sybase MDA table monSysStatement .. here u can check sql statement which is taking high Io, time, number of row affecting etc.
精彩评论