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

Refactor _process_results to support new DB engines #1053

Closed
dantownsend opened this issue Jul 21, 2024 · 0 comments · Fixed by #1054
Closed

Refactor _process_results to support new DB engines #1053

dantownsend opened this issue Jul 21, 2024 · 0 comments · Fixed by #1054
Labels
enhancement New feature or request

Comments

@dantownsend
Copy link
Member

dantownsend commented Jul 21, 2024

I'm one of the developers behind psqlpy. We've created a third-party library, which you can check out here. However, we've encountered a small problem that makes the integration nearly impossible without your assistance.

The issue lies within the _process_results method, where some unwrapping is performed. Asyncpg returns a Record object, but psqlpy does not. Instead, it behaves more like SQLite in this context, returning a list of dictionaries. Therefore, we don't need this unwrapping. Unfortunately, there is no appropriate engine type for our use case. We cannot use the SQLite engine type for obvious reasons.

Would it be possible to add a psqlpy-postgres type, so we can eliminate this Record object unwrapping?

Additionally, this change needs to be reflected in the Query class within the querystrings property. There might be other places affected, but these are what I identified during my reverse engineering.

Looking forward to our collaboration!

Originally posted by @insani7y in #986 (comment)

As outlined above, there's a bit of code where we transform the response from the database into a list of dicts:

if self.engine_type in ("postgres", "cockroach"):
# asyncpg returns a special Record object. We can pass it
# directly into zip without calling `values` on it. This can
# save us hundreds of microseconds, depending on the number of
# results.
raw = [dict(zip(keys, i)) for i in results]

It assumes that Postgres engines will just be asyncpg based, which is no longer the case.

We should move this logic to the Engine class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant