views:

130

answers:

0

I'm running SQLAlchemy on Jython and trying to connect to a MS SQL database using jTDS with windows authentication. I can query and delete just fine but when I try to insert new values it will hang when I commit.

print 'before add'
session.add(newVal)
print 'after add'
session.commit()
print 'after commit'

I see the first two print statements but not the last. My CPU maxes out and I can't even query the table directly using the MS SQL Management Studio. When I kill the Jython java process I can query again but the new values haven't been added.

Strangely enough I can insert values directly using an SQL command:

insert_sql = "INSERT INTO my_table (my_value) VALUES ('test_value')"
session.execute(insert_sql)
session.commit()

Any ideas what I'm doing wrong?

Here is a shortened stack trace:

"MainThread" prio=6 tid=0x0000000000def000 nid=0x528 runnable [0x0000000002c3d000]
   java.lang.Thread.State: RUNNABLE
    at java.lang.Throwable.fillInStackTrace(Native Method)
    - locked <0x0000000021e98880> (a org.python.core.PyException)
    at org.python.core.PyException.fillInStackTrace(PyException.java:70)
    at java.lang.Throwable.<init>(Throwable.java:181)
    at java.lang.Exception.<init>(Unknown Source)
    at java.lang.RuntimeException.<init>(Unknown Source)
    at org.python.core.PyException.<init>(PyException.java:46)
    at org.python.core.PyException.<init>(PyException.java:43)
    at org.python.core.PyException.<init>(PyException.java:61)
    at org.python.core.Py.AttributeError(Py.java:145)
    at org.python.core.PyObject.noAttributeError(PyObject.java:936)
    at org.python.core.PyObject.object___getattribute__(PyObject.java:3694)
    at org.python.core.PyObject$object___getattribute___exposer.__call__(Unknown Source)
    at org.python.core.PyObjectDerived.__findattr_ex__(PyObjectDerived.java:993)
    at org.python.core.PyObject.__getattr__(PyObject.java:929)
    at sqlalchemy.dialects.mssql.zxjdbc$py.post_exec$3(C:\Users\pchavez\bin\netbeans\NetBeans 6.7 Python EA2\python1\jython-2.5\Lib\site-packages\sqlalchemy\dialects\mssql\zxjdbc.py:52)
    at sqlalchemy.dialects.mssql.zxjdbc$py.call_function(C:\Users\pchavez\bin\netbeans\NetBeans 6.7 Python EA2\python1\jython-2.5\Lib\site-packages\sqlalchemy\dialects\mssql\zxjdbc.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:165)

    ...

    at org.python.pycode._pyx0.f$0(C:\Users\pchavez\sqltool\src\db\sqltest.py:99)
    at org.python.pycode._pyx0.call_function(C:\Users\pchavez\sqltool\src\db\sqltest.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:165)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.Py.runCode(Py.java:1197)
    at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:166)
    at org.python.util.jython.run(jython.java:229)
    at org.python.util.jython.main(jython.java:117)

From what I can tell it is an infinate loop in the sqlalchemy.dialects.mssql.zxjdbc module:

def post_exec(self):
    if self._embedded_scope_identity:
        while True:
            ...