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

Is there an option to return execute_sql results as a list of dictionaries? #958

Closed
yaozhang09 opened this issue Jun 8, 2023 · 5 comments · Fixed by #1003
Closed

Is there an option to return execute_sql results as a list of dictionaries? #958

yaozhang09 opened this issue Jun 8, 2023 · 5 comments · Fixed by #1003
Assignees
Labels
api: spanner Issues related to the googleapis/python-spanner API.

Comments

@yaozhang09
Copy link

yaozhang09 commented Jun 8, 2023

right now the results returned from snapshot.execute_sql() gets returned as a list of arrays. Is there an existing configuration to change the return format of the StreamedResultSet object?

I would like to use keys instead of row indices when pulling values out for further processing. If i ever had to update the running query I would have to make sure my indices are correct. I can easily convert the row to dictionary but want to see if there's a configuration i'm missing.

@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner API. label Jun 8, 2023
@asthamohta
Copy link
Contributor

hi @yaozhang09, currently we don't. If you like we can add an additional function which you can use on the result returned. But we won't be able to change the existing functionality as it will be breaking change. Let me know 😊

@yaozhang09
Copy link
Author

that would be great if another function that would allow us to return the results in a different format, thanks for letting me know!

@asthamohta
Copy link
Contributor

Sure give me some time. Thanks

@asthamohta
Copy link
Contributor

Hi @yaozhang09, can you check if this is as requested? https://github.com/googleapis/python-spanner/pull/1003/files

@yaozhang09
Copy link
Author

sorry just following up, this LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants