v.db.connect: Add JSON support#6077
Conversation
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
wenzeslaus
left a comment
There was a problem hiding this comment.
Going deeper into this, I now see that #6014 does not capture all the complexity.
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
wenzeslaus
left a comment
There was a problem hiding this comment.
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 -cpignores-cand prints the same as-p.v.db.connect streets -c format=csvprints 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 <nishant.bansal.282003@gmail.com>
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. |
wenzeslaus
left a comment
There was a problem hiding this comment.
Markdown doc can spec json, instead of text, for JSON examples.
wenzeslaus
left a comment
There was a problem hiding this comment.
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.connectmodule. The JSON output looks like:-pflag:[ { "layer": 1, "name": "roadsmajor", "table": "roadsmajor", "key": "cat", "database": "$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db", "driver": "sqlite" }, ...... ]-cflag:[ { "name": "cat", "type": "INTEGER" }, { "name": "MAJORRDS_", "type": "DOUBLE PRECISION" }, ...... ]This PR includes the following changes:
formatoption withplain,csv, andjsonmodes for output formatting.format = csvoption; the-gflag is now deprecated.-pflag, and CSV for the-gand-cflags.