Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get col_names? #115

Open
hai1y1kr opened this issue Apr 15, 2022 · 2 comments
Open

How can I get col_names? #115

hai1y1kr opened this issue Apr 15, 2022 · 2 comments

Comments

@hai1y1kr
Copy link

cursor.description return None

@anikolaienko
Copy link

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

@hai1y1kr
Copy link
Author

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants