-
-
Notifications
You must be signed in to change notification settings - Fork 365
v.db.connect: Add JSON support #6077
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
Conversation
Signed-off-by: Nishant Bansal <[email protected]>
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.
Going deeper into this, I now see that #6014 does not capture all the complexity.
Signed-off-by: Nishant Bansal <[email protected]>
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.
Thanks for the updates. I have tested the parameter combinations I raised up and they work great now.
I have three further comments, but I don't know if we need to pursue them:
v.db.connect streets -cp
ignores-c
and prints the same as-p
.v.db.connect streets -c format=csv
prints columns in order sql_type, name. Would name, sql_type be better? But I know that this would require even more code to keep the backwards compatibility.- Default separator: We may have this issue elsewhere too, but I realized that only now. CSV should by default have comma, not pine. v.db.select deals with that in the way that by default, the separator is not set, for plain format and in legacy mode, it uses pipe, but for explicit format=csv it uses comma. For format=json, the separator can be ignored, but I think v.db.select complains because now it was set explicitly and it does not make sense.
This could be simply solved using the parser rules, no?
I would say low priority
I believe we attempted to handle that in the other cases. So yes, this should be fixed. |
Signed-off-by: Nishant Bansal <[email protected]>
Addresses all of these in the latest commit, hope that makes sense. Also, for (2), the code was not that much, so I added that case as well. |
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.
Markdown doc can spec json, instead of text, for JSON examples.
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.
This is good to go. Thank you for the fine tuning.
Sorry for the noise with the highlight language for the examples. I didn't realize it is clearly meant as a Python print. It should be good to go now.
Fixes: #6014
This PR adds JSON support to the
v.db.connect
module. The JSON output looks like:-p
flag:-c
flag:This PR includes the following changes:
format
option withplain
,csv
, andjson
modes for output formatting.format = csv
option; the-g
flag is now deprecated.-p
flag, and CSV for the-g
and-c
flags.