如何在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
答案 0 :(得分:5)
当JayDeBeApi实现DB-API时,请检查PEP 249's .description attribute。 这应该有效:
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