-
Notifications
You must be signed in to change notification settings - Fork 169
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
capture queryset as list of dictionaries. #102
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests to test_dbapi.py
. The test should contain duplicated column names case.
Also, here is git commit message guideline.
https://chris.beams.io/posts/git-commit/
If you use debian or redhat linux distributions. you may need to install following to be able to install pip packages: | ||
|
||
for Debian/Ubuntu/etc: | ||
``` | ||
$ sudo apt-get install gcc python-dev libkrb5-dev | ||
``` | ||
|
||
for RHEL/CentOS/etc: | ||
``` | ||
$ sudo yum install gcc python-devel krb5-devel krb5-workstation python-devel | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend separating a PR since it's unrelated to dictionary change.
def fetchjson(self): | ||
columns = [col['name'] for col in self._query.columns] | ||
rows = self.fetchall() | ||
return [dict(zip(columns, item)) for item in rows] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we implement like this, there is less benefit because users can achieve the same thing easily with the existing code and cannot use in case of fetchone
. Could you take a look at other library's implementation I shared in the issue?
Let me close this PR since there's no update for a while. Please feel free to reopen if you still want to continue the work. |
I have made an issue for this matter some hours ago: issue
I have tried to make a new method for the Cursors to fetch data and represent them as a list of dictionaries.
Each dictionary contains a row of data with the data columns as keys.
I believe that this feature is fully backward compatible and won't make a difficulty for previous users.
I also added some docs to use this method to readme file.
I would be honored to know your opinion on adding this feature to the package.