开发者

how to do a select * in jython and get the result

how to do a select * from table in jython and get the resu开发者_C百科lt for each row into a list or string. i know how to do for select counmn_name1 ,column_name2 from table1 but not able to figure out for select *

Please suggest .thanks


If you use JDBC then you can use JDBC ResultSetMetaData interface:

    rs = c.executeQuery("SELECT * FROM a_tmp_table")
    while (rs.next()):
        rsmd = rs.getMetaData()
        print('columnCnt: %d' % (rsmd.getColumnCount()))
        for i in range(rsmd.getColumnCount()):
            print(rs.getString(i + 1))


If you use zxJDBC (comes with Jython) then you can follow the cross-implementation DB-API protocol to execute queries and retrieve results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜