Add interface to get results in standard formats from run_raw_sql #1583
Labels
feature
New feature or request
priority/high
High priority
product/python-sdk
Label describing products
Milestone
Please describe the feature you'd like to see
When I use
aql.run_raw_sql
, I find myself writing handlers like:@aql.run_raw_sql(..., handler = lambda x: x.fetchall())
@aql.run_raw_sql(..., handler = pd.DataFrame(x.fetchall(), columns = x.keys()))
It seems like there are a few natural results formats (list, dataframe) that you'd want to get results in, but the user is responsible for making these handlers. Additionally, I can't just use the same handler for both
SELECT
andCREATE TABLE
functions because sqlalchemy's ResultProxy errors if there are no results and you callx.fetchall()
Describe the solution you'd like
Add two fields to the decorator/operator:
results_format
: let the user specify a common format they want their results (list, dataframe)fail_on_empty
: let the user decide what the behavior should be if there are no resultsAre there any alternatives to this feature?
We could also consider exporting common handlers instead of forcing the user to define them.
Additional context
Add any other context about the feature request here.
I'm considering this from the perspective of the Astro Cloud IDE, in which our requirements are:
SELECT
orINSERT
Acceptance Criteria
The text was updated successfully, but these errors were encountered: