[{"data":1,"prerenderedAt":318},["ShallowReactive",2],{"project-20763892":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":34,"aspects":35,"strip":44,"post_text":46,"what":47,"said":86,"maker_in_thread":191,"shape":195,"grid":200,"attempts":282,"same_week":283,"maker_shows":40,"maker_hidden":310,"reader_version":311,"card":312},"20763892","pgcmd","An alternative to psql with JSON output","title","Show HN: pgcmd – An alternative to psql with JSON output","https:\u002F\u002Fgithub.com\u002Fsoheilpro\u002Fpgcmd","github.com","soheilpro",1566438533,2019,76,35,618,2195,29,"notable","dev_tools","database cli","cli",[24,25,26,27],"postgresql","psql","json output","postgres cli","roasted",-0.286,{"positive":31,"neutral":32,"mixed":31,"critical":33},1,6,8,16,{"execution":36,"idea":39,"privacy":41,"docs":42,"performance":43},{"positive":37,"critical":38},0,2,{"positive":31,"critical":40},5,{"positive":37,"critical":37},{"positive":37,"critical":37},{"positive":37,"critical":31},[45,37,37,37,37,31,37,45,31,37,45,45,40,37,45,45,37,37,31,45,31,31,31,37,37,37,37,37,31,37,31,37,37,37,37],3,null,{"problem":48,"audience":55,"pricing":46,"motivation":63,"time_to_build":46,"stack":67,"openness":84,"stage":85,"team_size":85},{"value":49,"source":50,"evidence":51},"Running SQL files against Postgres and processing results with other tools needs JSON output.","maker",[52],{"id":53,"by":11,"text":54},"20764421","I made this because I have a bunch of .sql files that I want to run against Postgres and then process the results with other tools. I cannot simply go and add json_agg to them.",{"value":56,"source":57,"evidence":58},"Developers who run Postgres queries and process results with other tools.","inferred",[59,60],{"id":53,"by":11,"text":54},{"id":61,"by":11,"text":62},"20764432","Yes, it's essentially one line of code but it makes my daily routine of running queries against Postgres and then processing the results with other tools much easier.",{"value":64,"source":50,"evidence":65},"Run .sql files against Postgres and process results with other tools without editing the queries.",[66],{"id":53,"by":11,"text":54},[68,79],{"value":69,"source":57,"evidence":70},"JavaScript",[71,75],{"id":72,"by":73,"text":74},"20765000","travislane","What is the motivation behind writing tools like these in JavaScript? Not everyone is going to have Node or NPM. I don't want to first install NPM to install a utility. But…",{"id":76,"by":77,"text":78},"20764354","byteshock","Just to be clear your “library” is literally one line of code: ``` console.log(JSON.stringify(rows, null, 2)); ``` So what’s the point?",{"value":80,"source":57,"evidence":81},"Node.js",[82,83],{"id":72,"by":73,"text":74},{"id":76,"by":77,"text":78},"open_source","unknown",{"praise":87,"objections":97,"requests":132,"questions":155,"alternatives":167},[88],{"value":89,"source":90,"evidence":91},"Useful for piping Postgres results into other tools.","commenter",[92,96],{"id":93,"by":94,"text":95},"20764789","Renevith","I can see this being convenient. I'm surprised that json isn't one of the output formats for pgcli, given that there are already tons of formats including one optimized for Jira…",{"id":61,"by":11,"text":62},[98,110,124],{"value":99,"source":90,"evidence":100},"Node dependency is a burden compared with Python, Perl or Go binaries.",[101,102,106],{"id":72,"by":73,"text":74},{"id":103,"by":104,"text":105},"20765645","rswail","This wasn’t a hate post. It was a legitimate question. My systems have python by default. Why do I want to add another dependency for node plus it’s inherent requirement for…",{"id":107,"by":108,"text":109},"20767878","koolba","Sure they have python, but which version of python do they have? 2? 3? 3.5? 3.7? Arguably writing command line tools in Node.js has similar problems (8? 10? 12? 12.9?) though it…",{"value":111,"source":90,"evidence":112},"Can be done with psql or json_agg directly.",[113,117,121],{"id":114,"by":115,"text":116},"20764338","llarsson","What, besides being implemented in Node, makes this substantially different from using the built in json_agg function from Postgres, as in:…",{"id":118,"by":119,"text":120},"20764382","bagol","psql with right query and right flag can do that.",{"id":122,"by":119,"text":123},"20768756","Use --tuples-only \u002F -t and --no-align \u002F -A. Or -tA for short. For example: ``` $ psql dbname -tAc 'SELECT json_agg(some_table) FROM some_table' ``` That will produce a valid JSON…",{"value":125,"source":90,"evidence":126},"A single line of core logic does not justify a library.",[127,128],{"id":76,"by":77,"text":78},{"id":129,"by":130,"text":131},"20765069","thunderbong","I guess the reason this is getting downvoted is because there isn't sufficient information in the comment. It's true, however. I find this is rampant in the Node community - For…",[133,140,144,148],{"value":134,"source":90,"evidence":135},"Support postgresql: connection URIs.",[136],{"id":137,"by":138,"text":139},"20765015","cryptonector","Cool! Now, can we just always use postgresql: scheme URIs for connection information? Also, no passwords on the command-line please -- use a password file, or prompt. Also,…",{"value":141,"source":90,"evidence":142},"Avoid passwords on the command line; use a password file or prompt.",[143],{"id":137,"by":138,"text":139},{"value":145,"source":90,"evidence":146},"Add GSS-API support.",[147],{"id":137,"by":138,"text":139},{"value":149,"source":90,"evidence":150},"Release standalone binaries for major platforms.",[151],{"id":152,"by":153,"text":154},"20771776","quickthrower2","The nicest thing to do is release binaries for all major platforms (dependency free if possible). Then code it in whatever you want.",[156,160],{"value":157,"source":90,"evidence":158},"Why write it in JavaScript instead of Perl, Python or Ruby?",[159],{"id":72,"by":73,"text":74},{"value":161,"source":90,"evidence":162},"Which psql flags or queries produce JSON output?",[163],{"id":164,"by":165,"text":166},"20764542","daniub","Can you share that query and flag please?",[168,180,184],{"value":169,"source":90,"evidence":170},"psql with row_to_json or json_agg",[171,172,176],{"id":114,"by":115,"text":116},{"id":173,"by":174,"text":175},"20764634","kbaker","I was sure most of this existed so I looked it up... Mostly centers around adding row_to_json() to the query. Using the example from the github repo: ``` $ psql -P pager -nqtc…",{"id":177,"by":178,"text":179},"20768812","eddyg","``` select array_to_json(array_agg(row_to_json(t))) from (select * from name) t ``` seems to work...",{"value":181,"source":90,"evidence":182},"pgcli",[183],{"id":93,"by":94,"text":95},{"value":185,"source":90,"evidence":186},"Copy to stdout with CSV converted via jq",[187],{"id":188,"by":189,"text":190},"20765424","mhd","Another approach to this is wrapping the query in a `copy to stdout` statement (either in the .sql or with a tiny wrapper), then converting the CSV to JSON. If you're doing the…",{"comments":38,"answered":31,"key":192},[193,194],{"id":53,"text":54},{"id":61,"text":62},{"commenters":196,"max_depth":197,"maker_replies":38,"first_comment_mins":198,"lifespan_hours":199},31,4,90,18,[201,203,207,208,211,214,216,219,223,226,229,232,233,235,239,241,243,246,248,250,252,253,255,256,258,261,264,267,268,269,270,273,276,277,279],[72,37,45,202,73,37],"project\u002Fneutral\u002Fexecution",[204,37,37,205,206,37],"20765428","commenter\u002Fneutral\u002Fnone","paulcarroty",[103,37,37,205,104,37],[209,37,37,205,210,37],"20765680","dewey",[212,37,37,205,213,37],"20767685","slantyyz",[107,37,31,215,108,37],"project\u002Fcritical\u002Fexecution",[217,37,37,205,218,37],"20770298","gramakri",[220,37,45,221,222,37],"20765932","project\u002Fmixed\u002Fexecution","dagw",[224,37,31,215,225,37],"20766125","inferiorhuman",[227,37,37,205,228,37],"20766885","IggleSniggle",[230,37,45,202,231,37],"20767160","nicoburns",[152,37,45,202,153,37],[93,31,40,234,94,37],"project\u002Fpositive\u002Fidea",[236,31,37,237,238,37],"20771779","other\u002Fneutral\u002Fnone","ORioN63",[137,38,45,240,138,37],"project\u002Fneutral\u002Fprivacy",[188,45,45,242,189,37],"project\u002Fneutral\u002Fidea",[244,45,37,205,245,37],"20766450","Piskvorrr",[247,45,37,205,189,37],"20768231",[118,197,31,249,119,37],"project\u002Fcritical\u002Fidea",[164,197,45,251,165,37],"project\u002Fneutral\u002Fdocs",[173,197,31,249,174,37],[122,197,31,254,119,37],"project\u002Fcritical\u002Fperformance",[114,40,31,249,115,37],[53,40,37,257,11,31],"maker\u002Fneutral\u002Fidea",[259,40,37,205,260,37],"20764536","teej",[262,40,37,205,263,37],"20764563","striking",[265,40,37,205,266,37],"20768190","newaccoutnas",[177,40,37,205,178,37],[76,32,31,249,77,37],[61,32,37,234,11,31],[271,32,31,249,272,37],"20765637","goatinaboat",[274,32,37,237,275,37],"20764781","techntoke",[129,32,37,237,130,37],[278,32,37,237,272,37],"20765592",[280,32,37,237,281,37],"20765030","johnisgood",[],[284,288,293,297,302,306],{"id":285,"name":286,"points":287,"category":20},"20774322","monolith",640,{"id":289,"name":290,"points":291,"category":292},"20813557","fkMigration.jl",375,"languages",{"id":294,"name":295,"points":296,"category":20},"20817627","I created Postwoman",280,{"id":298,"name":299,"points":300,"category":301},"20798003","Wobaka",275,"web_saas",{"id":303,"name":304,"points":305,"category":20},"20800157","portray",233,{"id":307,"name":308,"points":309,"category":301},"20790129","Sourcery",230,false,"v2",{"id":313,"name":5,"line":6,"ai":310,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":314,"top":18,"kw":315,"maker":11,"domain":10,"tier":19,"attempts":37,"strip":316,"url":9,"mix":317,"praise":89,"objection":99,"sub":21},20763892,-0.29,[24,25,26,27],"30000103103350330013111000001010000",[31,32,31,33],1794036580078]