-1

I wrote a python program (with SQL queries) that generally runs fine, but every once in a while it will hang until I click into the command line and press Enter. I usually run it in Anaconda prompt, but I have also used PyInstaller to wrap it in an executable and the problem persists. The problem also persists if I don't click away from the program.

I have print statements throughout the program and it does not necessarily stop at a specific spot, but it does always seem to happen during/after an SQL query. I'm using an Oracle db and importing cx_Oracle to read from it. There are no returned errors, it just gets stuck. This is a very inconsistent issue: running it the exact same way with the same values won't necessarily replicate the issue.

I know this is a somewhat generic problem, but I feel like there is no low-hanging fruit to try because of how inconsistent this issue is. Any troubleshooting advice would be helpful.

This is how I'm reading from the database: (server info is omitted)

def readFromServer(command):
    CONN_INFO = { 'host': 'HOST', 'port': PORT, 'user': 'USER', 'psw': 'PSW', 'service': 'SERVICE', }
    CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO)
    connection = cx_Oracle.connect(CONN_STR)
    cursor = connection.cursor()
    cursor.execute(command)
    commandData = []
    for i in cursor:
        commandData.append(i)
    return commandData

I did not include the full code because it is too long/IP issues. I can't show the sql command string, but given that it is just a slightly modified version of one that definitely works, I'm pretty sure that's not the problem. Essentially what my script does is reading user input from the gui, pulling the applicable data from an oracle server, simple data processing, then displaying the results in a gui.

I found multiple posts like this one that seems to have similar issues, but they generally revolve around powershell or command line input and those issues seem to consistently occur.

  • post a abbreviated comand that works and one of that not works, change column nmes table names to something generic – nbk Aug 11 '23 at 15:45
  • All of the commands work most of the time--there's no specific ones that work or don't work. I can run it exactly the same way and sometimes I'll get the issue, sometimes I won't – user22333282 Aug 11 '23 at 15:59
  • the execute comand hangs till you press any button? that sounds more that another code is interfering – nbk Aug 11 '23 at 16:07
  • Is the data locked by another SQL statement from another user or program? Are you 'clicking into the command line' in a tool like SQL Developer or SQL*Plus? – Christopher Jones Aug 12 '23 at 00:10

0 Answers0