-
Notifications
You must be signed in to change notification settings - Fork 4.5k
query_runner -> query_results: improve logging, handle unhandled data types #6905
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
base: master
Are you sure you want to change the base?
Changes from 12 commits
aa7b93c
fb4163c
4e7e468
11e4f0b
1f4853e
e0ae3ba
051ed07
71e433a
17c00d6
512bde7
be111d3
26b5f7c
8d155bf
374e6bf
1a7f204
d22df7c
30776b3
c9feda5
a181ba9
d3f8cad
0778b71
a8023fb
4e3cbdb
5e69e3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,9 +109,13 @@ def flatten(value): | |
return json_dumps(value) | ||
elif isinstance(value, decimal.Decimal): | ||
return float(value) | ||
elif isinstance(value, datetime.timedelta): | ||
elif isinstance(value, (datetime.date, datetime.time, datetime.datetime, datetime.timedelta)): | ||
return str(value) | ||
elif value is None: | ||
return 'NULL' | ||
else: | ||
if not isinstance(value, (str, float, int)): | ||
logger.debug("flatten() found new type: %s", str(type(value))) | ||
return value | ||
|
||
|
||
|
@@ -134,10 +138,19 @@ def create_table(connection, table_name, query_results): | |
column_list=column_list, | ||
place_holders=",".join(["?"] * len(columns)), | ||
) | ||
logger.debug("INSERT template: %s", insert_template) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure we don't want debugging statements being unconditionally run. At least with the change above it, it seems to be done conditionally there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @justinclift thank you for the reply! So there are 2 things:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping @justinclift There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vtatarin Sorry, but I'm short on time for the next few weeks. Am getting some (Redash related) stuff deployed to a data centre, and that's taking the majority of my focus time. When that's done I'll be able to look at PRs properly. 😄 |
||
|
||
for row in query_results["rows"]: | ||
values = [flatten(row.get(column)) for column in columns] | ||
# try: | ||
# for value in values: | ||
# logger.debug("Value: %s, Type: %s", str(value), str(type(value))) | ||
connection.execute(insert_template, values) | ||
# except Exception as e: | ||
# if logger.isEnabledFor(logging.DEBUG): | ||
# for value in values: | ||
# logger.debug("Value: %s, Type: %s", str(value), str(type(value))) | ||
# raise Exception("Error inserting data: %s", str(e)) | ||
|
||
|
||
def prepare_parameterized_query(query, query_params): | ||
|
Uh oh!
There was an error while loading. Please reload this page.