3

我如何在 jaydebeapi 中执行以下操作?

#In Java
ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");
ResultSetMetaData rsmd = rs.getMetaData();
String columnName = rsmd.getColumnName(0) ## basically i am interested with this part
4

1 回答 1

8

由于 JayDeBeApi 实现了 DB-API,请检查PEP 249 的 .description 属性。这应该有效:

import jaydebeapi
conn = jaydebeapi.connect(...)
curs = conn.cursor()
curs.execute('SELECT a, b, c FROM TABLE2')
column_name = curs.description[0][0]
assert column_name == 'a', column_name
于 2014-09-18T09:09:42.907 回答