prestodb / presto-python-client

Python DB-API client for Presto
Apache License 2.0
239 stars 87 forks source link

How can I get col_names? #115

Open hai1y1kr opened 2 years ago

hai1y1kr commented 2 years ago

cursor.description return None

anikolaienko commented 2 years ago

What's your query? My returns correctly in cursor.description

hai1y1kr commented 2 years ago

What's your query? My returns correctly in cursor.description This is my function,and all the cursor.description is None for different querys. def read_table(self, sql_sentence= r'show tables'): if self.is_connected(): logger.debug('='*40) logger.debug('Executing: ' + sql_sentence) start_time = time.time() try: if self.plantform == 'presto': sentence_1 = 'set session hive.parquet_fail_with_corrupted_statistics = false' self.cursor.execute(sentence_1) self.cursor.fetchall() self.cursor.execute(sql_sentence) self.con.commit() col_names = self.cursor.description rows = self.cursor.fetchall() logger.info('Got rows: ' + str(len(rows)) + ' time consumed: ' + str(time.time() - start_time)) except Exception as e: logger.error('read table failed: ' + str(e)) return rows, col_names else: logger.warn('warning: disconnected')