3

How can i do the following in 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
whb
  • 661
  • 2
  • 10
  • 22

1 Answers1

9

As JayDeBeApi implements the DB-API, check PEP 249's .description attribute. This should work:

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
bastian
  • 1,122
  • 11
  • 23