Issue1451
Created on 2009-09-01.03:49:35 by kezhifeng, last changed 2009-09-04.09:14:36 by kezhifeng.
msg5080 (view) |
Author: Kezhifeng (kezhifeng) |
Date: 2009-09-01.03:49:34 |
|
Hello, I use Jython2.5.0, mysql-connector-java-5.0.8-bin.jar, because my
sever is Mysql5.0.38 There is a problem in my Jython application.OS:ubuntu
Two functions:
def act_query(query):
connection = conn //conn is global and has been assigned when called
cursor = connection.cursor()
num_affected_rows = cursor.execute(query)
cursor.close()
connection.commit()
return num_affected_rows
def get_row(query):
connection = conn
cursor = connection.cursor()
cursor.execute(query)
row = cursor.fetchone()
cursor.close()
return row
Then i do something like this:
query = """SELECT 15 into @max"""
act_query(query)
get_query= """ select @max """
row = get_row(get_query)
print row
The output is something like: array('b', [49, 52])
I try to find the reason and make a test like:
test_query = """select @max = 15"""
row = get_row(test_query)
print row
The output is the right answer
|
msg5097 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2009-09-04.02:25:02 |
|
This is pretty much expected when using JDBC as MySQL treats variables
as VARBINARY, which most JDBC drivers (definitely MySQL's) return byte[]
for, so we return the Python analog, an array.array of bytes. You can
convert this to a string via bytes.tostring()
A byte array here is also currently more efficient than plain Python
strings for Jython as our str is backed by java.lang.String instead of
being a simple byte bucket like CPython's
When we change that (in Jython 3, or possibly before) we might want to
consider changing this behavior, but probably not until then
|
msg5099 (view) |
Author: Kezhifeng (kezhifeng) |
Date: 2009-09-04.09:14:35 |
|
Thanks very much for your help!
I use JDBC directly and convert the resultset into a dict with ResultsetMetadata, so I can get the value by a column name, which is not supported by zxJDBC but MySQLdb. Maybe it can be supported by Jython3.0.
Best wishes!
------------------
kezhifeng
2009-9-4
-----------------------------------------------------------------------------------------
发件人: Philip Jenvey <report@bugs.jython.org>
发送时间: 2009-09-04 10:25
主 题: [issue1451] zxJDBC, cursor.fetchone() for a session variable ,
I get an array .
收件人: kezhifeng08
Philip Jenvey <pjenvey@users.sourceforge.net> added the comment:
This is pretty much expected when using JDBC as MySQL treats variables
as VARBINARY, which most JDBC drivers (definitely MySQL's) return byte[]
for, so we return the Python analog, an array.array of bytes. You can
convert this to a string via bytes.tostring()
A byte array here is also currently more efficient than plain Python
strings for Jython as our str is backed by java.lang.String instead of
being a simple byte bucket like CPython's
When we change that (in Jython 3, or possibly before) we might want to
consider changing this behavior, but probably not until then
----------
nosy: +pjenvey
resolution: -> wont fix
status: open -> closed
_______________________________________
Jython tracker <report@bugs.jython.org>
<http://bugs.jython.org/issue1451>
_______________________________________
|
|
Date |
User |
Action |
Args |
2009-09-04 09:14:36 | kezhifeng | set | messages:
+ msg5099 title: zxJDBC, cursor.fetchone() for a session variable ,I get an array . -> zxJDBC, cursor.fetchone() for a session variable , I get an array . |
2009-09-04 02:25:02 | pjenvey | set | status: open -> closed resolution: wont fix messages:
+ msg5097 nosy:
+ pjenvey |
2009-09-01 03:49:35 | kezhifeng | create | |
|